elgon is a performance-oriented, API-first Go web framework built on top of net/http.
It provides production-focused defaults while keeping APIs explicit, modular, and easy to test.
- Fast routing with static, param, and wildcard path matching
- Low-overhead middleware pipeline
- Centralized typed error handling
- Built-in health and metrics support
- OpenAPI generation and Swagger UI serving
- Config loading from environment and JSON files
- Auth support (JWT, RBAC guards, OAuth2/OIDC helpers)
- Database adapters, migrations, and background jobs
- CLI commands for common development workflows
elgon: app lifecycle, router, context, handler/middleware contractsmiddleware: recover, request ID, logger, CORS, body limit, secure headersconfig: strict typed config loading (env,default,requiredtags)observability: metrics middleware/endpoint and tracing interfacesopenapi: route-driven OpenAPI generation with schema/tag annotationsauth: JWT auth, RBAC middleware, OAuth2/OIDC helpersdb: adapter abstractions and SQL adapter helpersorm: optional typed repositories overdb.Adaptermigrate: SQL migration loading and engine (up,down,status)jobs: in-memory queue, SQL distributed backend, Redis/Kafka queue interfaces
go get github.com/meshackkazimoto/elgonpackage main
import (
"log"
"log/slog"
"os"
"github.com/meshackkazimoto/elgon"
"github.com/meshackkazimoto/elgon/middleware"
"github.com/meshackkazimoto/elgon/observability"
"github.com/meshackkazimoto/elgon/openapi"
)
func main() {
app := elgon.New(elgon.Config{Addr: ":8080"})
metrics := observability.NewMetrics()
app.Use(
middleware.Recover(),
middleware.RequestID(),
middleware.Logger(slog.New(slog.NewJSONHandler(os.Stdout, nil))),
metrics.Middleware(),
)
app.GET("/users/:id", func(c *elgon.Ctx) error {
return c.JSON(200, map[string]string{"id": c.Param("id")})
})
metrics.RegisterRoute(app, "/metrics")
openapi.NewGenerator("Example API", elgon.Version).Register(app, "/openapi.json", "/docs")
if err := app.Run(); err != nil {
log.Fatal(err)
}
}A complete reference implementation is available at:
examples/demo-appexamples/prod-api
Run it with:
cd examples/demo-app
go mod tidy
go run ./cmd/apiProduction sample:
cd examples/prod-api
go mod tidy
go run ./cmd/apielgon includes a project CLI under cmd/elgon.
go run ./cmd/elgon --helpAvailable command groups include new, dev, test, bench, migrate, and openapi.
Standard development run:
make devHot reload (file watcher) with air:
make dev HOT_RELOAD=1elgon dev --hot-reload will use local air when available, and otherwise falls back to go run github.com/air-verse/air@latest.
You can also use the CLI directly:
go run ./cmd/elgon dev --hot-reloadgo test ./...
make bench-ci
make benchDB integration tests are env-driven and can be enabled with:
ELGON_DB_TEST_DRIVERELGON_DB_TEST_DSN
Concrete Redis and Kafka adapters are provided behind the adapters build tag:
jobs/redisadapter(go-redis)jobs/kafkaadapter(segmentio/kafka-go)
Build/test with adapters:
go test -tags adapters ./...
go build -tags adapters ./...adapter, _ := db.OpenSQLite(db.SQLiteConfig{})
app := elgon.New(elgon.Config{Addr: ":8080"})
app.SetSQL(adapter)
app.SetORMDialect("sqlite")
_, err := app.ORM().Table("users").Create(context.Background(), orm.Values{
"id": "usr_1",
"email": "kazimoto17@proton.me",
"name": "Meshack",
})
if err != nil {
log.Fatal(err)
}
user, err := app.ORM().Table("users").FindOne(context.Background(), orm.FindOptions{
Columns: []string{"id", "email", "name"},
Where: orm.Where{"id": "usr_1"},
})
if err != nil {
log.Fatal(err)
}
_ = user["email"]
_, _ = app.SQL().ExecContext(context.Background(), "UPDATE users SET name=? WHERE id=?", "M", "usr_1")- API stability:
docs/API_STABILITY.md - Module docs:
docs/modules/auth.mddocs/modules/openapi.mddocs/modules/jobs.mddocs/modules/migrate.mddocs/modules/orm.md
- Installation:
INSTALL.md - Releasing:
docs/RELEASING.md