A fast Go
web framework
on net/http.
Kern is a fast, zero-dependency Go HTTP framework with stdlib-native routing, context pooling, built-in middleware, and graceful shutdown — designed for production APIs without the bloat.
package main
import "github.com/mobentum/kern"
func main() {
app := kern.Default()
app.GET("/", func(c *kern.Context) {
c.JSON(200, map[string]string{
"message": "cosmic speed, zero gravity",
})
})
app.Run(":8080")
}See Kern in action
Real code, not hello world. Copy, paste, run.
package main
import "github.com/mobentum/kern"
type Task struct {
ID int `json:"id"`
Title string `json:"title" validate:"required,min=1"`
Completed bool `json:"completed"`
}
func main() {
app := kern.Default() // logger + recovery
app.Use(kern.CORS([]string{"*"}))
api := app.Group("/api/v1")
{
api.GET("/tasks", listTasks)
api.POST("/tasks", createTask)
api.GET("/tasks/{id}", getTask)
api.PATCH("/tasks/{id}", updateTask)
}
// graceful shutdown with 10s drain
app.Run(":8080", kern.WithGracefulShutdown(10))
}
func listTasks(c *kern.Context) {
c.OK(tasks)
}
func createTask(c *kern.Context) {
var t Task
if err := c.Bind(&t); err != nil {
c.JSONError(422, err.Error())
return
}
t.ID = nextID()
tasks = append(tasks, t)
c.Created(t)
}
func getTask(c *kern.Context) {
id := c.Param("id")
// lookup & return...
c.OK(task)
}
func updateTask(c *kern.Context) {
id := c.Param("id")
var t Task
if err := c.Bind(&t); err != nil {
c.JSONError(422, err.Error())
return
}
// update & return...
c.OK(updated)
}These examples work out of the box. More examples on GitHub →
A fast, production-ready Go web framework
Stdlib-native routing, zero dependencies, and built-in middleware for high-performance Go APIs
Stdlib-Native Routing
Built on Go 1.22+ net/http ServeMux with method-based routing, path parameters, and wildcard matching — no custom router to learn or debug.
Context Pooling
sync.Pool-backed Context reuse reduces GC pressure and allocation overhead, keeping your Go API server fast under high concurrency.
Built-in Middleware Suite
First-party middleware for JWT, CSRF, sessions, rate limiting, CORS, compression, security headers, request guards, and more — all net/http compatible.
Zero Dependencies
A single Go module with no external dependencies. Clean go.mod, fast builds, and a minimal supply chain — just import Kern and start building.
Graceful Shutdown
Built-in OS signal handling with configurable timeouts. Drain in-flight requests cleanly on SIGTERM/SIGINT — no dropped connections in production.
Unified Request Binding
Auto-detect method and Content-Type to bind from query, form, JSON, or XML. Struct tags with built-in validation keep your handlers clean and declarative.
File Upload & Streaming
Multipart file uploads with SaveFile, byte-range streaming with HTTP 206 Partial Content, and download helpers with Content-Disposition — all built in.
Lifecycle Hooks
OnRoute, OnListen, OnShutdown, and OnError hooks for observability, metrics, and graceful integration. Structured slog logging with per-request context.
Stdlib-First Design
A thin layer over net/http with zero custom abstractions. If you know Go's standard library, you already know Kern — onboard your team in minutes.
Why Kern over Gin, Fiber, or Chi?
No surprises. No lock-in. Just net/http, done right.
Stdlib, Not a Fork
Kern wraps net/http. Gin and Fiber fork or replace it. Your existing middleware, tooling, and knowledge carry over.
Zero Dependencies
Gin pulls 10+ transitive deps. Chi pulls protobuf. Kern's go.mod is empty. Your supply chain stays clean.
Pooled, Zero-Alloc Hot Paths
sync.Pool reuses Context objects. Plaintext and middleware paths are allocation-free — Gin and Chi can't say that.
Batteries Included
JWT, CSRF, sessions, rate limiting, CORS, compression, security headers, ETags, file streaming — all built in.
Benchmarks you can trust
Apple M3 Pro • Go 1.25 • Lower is better
| Scenario | Kern | Gin | Chi | Fiber | Note |
|---|---|---|---|---|---|
| Plaintext | 87 ns | 72 ns | 129 ns | 51 ns | 0 allocs |
| With Middleware | 100 ns★ | 116 ns | 154 ns | 102 ns | 0 allocs |
| Query Params | 108 ns★ | 297 ns | 343 ns | 98 ns | 0 allocs |
| JSON Decode | 546 ns★ | 664 ns | 680 ns | 506 ns | 272 B/op |
| Path Params | 213 ns | 113 ns | 300 ns | 122 ns | 48 B/op |
Benchmarks run via make bench-full • View full results on GitHub
Production-ready by default
Everything you need to ship — built in, not bolted on.
TLS & HTTPS
RunTLS() with cert/key files. Configurable read/write/idle timeouts. Keep-alive control.
Panic Recovery
Built-in Recovery() middleware logs stack traces and returns 500 — no crashed servers.
Server Timeouts
ReadTimeout, WriteTimeout, IdleTimeout, ReadHeaderTimeout, MaxHeaderBytes — all configurable.
Body Limits
WithBodyLimit() enforces MaxBytesReader at the framework boundary before your handler runs.
Trusted Proxies
CIDR-based trusted proxy config with strict X-Forwarded-For parsing. ClientIP() just works.
Graceful Shutdown
SIGTERM/SIGINT handling drains in-flight requests with configurable timeout. Zero dropped connections.
Structured Logging
Built-in slog support with request ID propagation. JSON or text output. Per-request logger override.
Request Guards
Per-route body size limits, header requirements, content-type whitelisting — enforced at the middleware layer.
Build your next Go API with Kern
Zero dependencies, stdlib-native routing, and production-ready middleware — one import away.
go get github.com/mobentum/kern