Go 1.22+ Native Routing

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.

0
Dependencies
87ns
Overhead vs stdlib
100%
Stdlib compatible
main.go
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")
}
$ go run main.go
[kern] Server started on :8080

See Kern in action

Real code, not hello world. Copy, paste, run.

main.go
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.

net/http.Handler compatible
Use any stdlib middleware
No custom context type to learn
📦

Zero Dependencies

Gin pulls 10+ transitive deps. Chi pulls protobuf. Kern's go.mod is empty. Your supply chain stays clean.

Single module, zero deps
No vulnerability churn
Fast CI, tiny binary

Pooled, Zero-Alloc Hot Paths

sync.Pool reuses Context objects. Plaintext and middleware paths are allocation-free — Gin and Chi can't say that.

0 allocs on plaintext routes
0 allocs with middleware
Lower GC pressure under load
🛠️

Batteries Included

JWT, CSRF, sessions, rate limiting, CORS, compression, security headers, ETags, file streaming — all built in.

15+ first-party middleware
File uploads & range streaming
Conditional requests & caching

Benchmarks you can trust

Apple M3 Pro • Go 1.25 • Lower is better

0
Dependencies
0ns
Plaintext Overhead
0%
Stdlib Compatible
0
Allocs (plaintext)
ScenarioKernGinChiFiberNote
Plaintext87 ns72 ns129 ns51 ns0 allocs
With Middleware100 ns116 ns154 ns102 ns0 allocs
Query Params108 ns297 ns343 ns98 ns0 allocs
JSON Decode546 ns664 ns680 ns506 ns272 B/op
Path Params213 ns113 ns300 ns122 ns48 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
Star on GitHub
MIT Licensed • Built by @mobentum