Skip to main content
Version: In development — v0.2.3

First steps

This guide creates a GET /hello endpoint, runs the application, and checks the response.

1. Configure the environment

Create .env in the project root:

ENVIRONMENT=development
APP_NAME=hello-colibri
APP_TYPE=service
CLOUD=none

These four variables are required.

2. Create the application

Create main.go:

package main

import (
"net/http"

"github.com/colibriproject-dev/colibri-sdk-go"
"github.com/colibriproject-dev/colibri-sdk-go/pkg/web/restserver"
)

type helloResponse struct {
Message string `json:"message"`
}

var routes = []restserver.Route{
{
URI: "hello",
Method: http.MethodGet,
Prefix: restserver.NoPrefix,
Function: func(ctx restserver.WebContext) {
ctx.JsonResponse(http.StatusOK, &helloResponse{
Message: "Hello, Colibri!",
})
},
},
}

func main() {
colibri.InitializeApp()
restserver.AddRoutes(routes)
restserver.ListenAndServe()
}

The root package is named colibri; the import ends in colibri-sdk-go, with no /colibri suffix.

3. Run and verify

go run .

The default port is 8080. From another terminal:

curl --fail --silent http://localhost:8080/hello

Expected response:

{"message":"Hello, Colibri!"}

The server also exposes GET /health and GET /api-docs when ./docs/swagger.json exists.