Getting Started
ss-keel-core is a Go web framework built on top of Fiber v2. It provides a structured, opinionated foundation for building production-ready REST APIs with built-in OpenAPI docs, structured logging, validation, health checks, and graceful shutdown.
Requirements
Section titled βRequirementsβ- Go 1.21 or later
Installation
Section titled βInstallationβgo get github.com/slice-soft/ss-keel-coreProject Structure
Section titled βProject StructureβA typical ss-keel-core project looks like this:
myapp/βββ main.goβββ config/β βββ config.go β environment variables loaded hereβββ users/β βββ module.goβ βββ controller.goβ βββ service.goβββ auth/ βββ module.go βββ guard.goYour First App
Section titled βYour First Appβ1. Load configuration
Section titled β1. Load configurationβCreate config/config.go to centralise all environment variables:
package config
import ( "os" "strconv")
type Config struct { ServiceName string Port int Env string}
func Load() Config { port, _ := strconv.Atoi(getEnv("PORT", "3000"))
return Config{ ServiceName: getEnv("SERVICE_NAME", "my-api"), Port: port, Env: getEnv("ENV", "development"), }}
func getEnv(key, fallback string) string { if v := os.Getenv(key); v != "" { return v } return fallback}2. Create the app
Section titled β2. Create the appβpackage main
import ( "myapp/config" "github.com/slice-soft/ss-keel-core/core")
func main() { cfg := config.Load()
app := core.New(core.KConfig{ ServiceName: cfg.ServiceName, Port: cfg.Port, Env: cfg.Env, Docs: core.DocsConfig{ Title: "My API", Version: "1.0.0", Description: "A simple REST API", }, })
app.Listen()}3. Add a route
Section titled β3. Add a routeβRoutes are registered through Controllers. A controller is any struct that implements Routes() []Route.
type HelloController struct{}
func (c *HelloController) Routes() []core.Route { return []core.Route{ core.GET("/hello", c.hello). Tag("hello"). Describe("Say hello", "Returns a greeting message"), }}
func (c *HelloController) hello(ctx *core.Ctx) error { return ctx.OK(map[string]string{"message": "Hello, World!"})}Register it in main.go:
app.RegisterController(&HelloController{})app.Listen()4. Run it
Section titled β4. Run itβgo run main.go# or with env varsPORT=8080 ENV=development go run main.goYour API is now running on http://localhost:3000.
Built-in endpoints available out of the box:
| Endpoint | Description |
|---|---|
GET /hello | Your route |
GET /health | Health check |
GET /docs | Swagger UI |
GET /docs/openapi.json | OpenAPI 3.0 spec |
The
/docsendpoint is only available whenEnvis not"production".
Whatβs Next
Section titled βWhatβs Nextβ- Configuration β env vars,
.envfiles, Docker setup - Controllers β structure routes and handlers
- Modules β organize the app into reusable modules
- Logger β structured logging across your application
- Error Handling β return structured errors
- Testing β write unit tests for your controllers