Procyon

Quick Start

Create and run a small Procyon HTTP application.

Quick Start

Create a Go module and add Procyon.

go mod init example.com/hello
go get -u codnect.io/procyon/...

Create a controller.

package main

import (
    "codnect.io/procyon/component"
    "codnect.io/procyon/http"
)

type HelloController struct{}

func NewHelloController() *HelloController {
    return &HelloController{}
}

func (h *HelloController) ConfigureEndpoints(endpoints http.Endpoints) {
    endpoints.MapGet("/hello", http.Handle(h.sayHello))
}

func (h *HelloController) sayHello(ctx *http.Context) error {
    _, err := ctx.Response().Writer().Write([]byte("Hello, World!"))
    return err
}

func init() {
    component.Register(NewHelloController)
}

Start the application.

package main

import (
    "os"

    "codnect.io/procyon"
)

func main() {
    if err := procyon.Run(); err != nil {
        os.Exit(1)
    }
}

Run it.

go run .

On this page