Procyon

Procyon

  • Documentation
  • Modules
  • Help
  • Blog

›Getting Started

Getting Started

  • Introduction
  • Quickstart
  • Benchmarks
  • Features

Features

Procyon offers several features to make development process easier. Thanks to them, you code your application and deploy fast. The most important feature offered by Procyon is Dependency Injection. While application starts, instances are automatically injected.

Here are all list of features offered:

  • Dependency Injection
  • Project Structure
  • Routing
  • Logger
  • Configurable
  • Fast
  • Events
  • Interceptors
  • Error Handling
  • Request and Path Variable Binding
  • Extendable

Dependency Injection

Dependency injection is not supported by standard libraries in Go. However, A few libraries like Wire developed by Google support it at compile-time while Procyon offers it at runtime. It's the first http framework supporting the dependency injection at runtime. Instances created by procyon are called 'Peas'.

Note that you need to register construction functions by using the function core.Register because Go doesn't support something like annotation in Java.

The example is given below.

package main

type Struct1 struct {
    // fields...
}

func newStruct1() Struct1 {
    return Struct1{}
}

type Struct2 struct {
    struct1 Struct1
    // fields ...
}

func newStruct2(struct1 Struct1) Struct2 {
    return Struct2{
        struct1,
    }
}

func init() {
    core.register(newStruct1)
    core.register(newStruct2)
}

...

Project Structure

Thanks to the dependency injection, you can organize your project structure like Controller-Service-Repository. You can look into the test application to understand how to use.

Routing

You can easily register your handler methods by using HandlerRegistry in the method RegisterHandlers.

func (controller HelloWorldController) RegisterHandlers(registry web.HandlerRegistry) {
    registry.Register(
        web.NewHandler(controller.HelloWorld, web.WithPath("/api/helloworld"))
    )
}

Logger

Procyon offers a standard logger for logging. It can be got through dependency injection.

The example is given below.

package main

import (
    context "github.com/procyon-projects/procyon-context"
)

type TestController struct {
    logger     context.Logger
}

func newTestController(logger context.Logger) TestController {
    return TestController{}
}

Configurable

Procyon application can be easily configured because it is designed according to configuration properties. For example, when you want application to start on port 3000, what you need to do is to specify the command-line parameter --server.port as 3030. Procyon application contains many configuration properties like this.

Also, You can define your configuration struct and its fields are automatically filled.

Note that you need to register your configuration struct.

The example is given below.

package main

type MyProperties struct {
    Port              int       `yaml:"port" json:"port" default:"8080"`
    ApplicationName   string    `yaml:"name" json:"name" default:"Test Application"`
}

func newMyProperties() *MyProperties {
    return &MyProperties{}
}

func (properties *MyProperties) GetPrefix() string {
    return "myproperties"
}

func init() {
    core.register(newMyProperties)
}

Fast

You can look into the benchmark result to find out how fast Procyon is.

Events

The integration of events hasn't been completed yet.

Interceptors

The integration of interceptors hasn't been completed yet.

Error Handling

The integration of error handling hasn't been completed yet.

Request and Path Variable Binding

The integration of error handling hasn't been completed yet.

Extendable

It's easier to extend the application. You can look into the modules to find out how to do.

← Benchmarks
  • Dependency Injection
  • Project Structure
  • Routing
  • Logger
  • Configurable
  • Fast
  • Events
  • Interceptors
  • Error Handling
  • Request and Path Variable Binding
  • Extendable
Procyon
Modules
ProcyonProcyon CoreProcyon ContextProcyon WebProcyon Peas
Community
Discord
More
BlogGitHubStar
Copyright © 2020 Procyon