Kern

Introduction

Kern is a lightweight Go web framework for fast API servers, stdlib-native routing, low overhead middleware, and production-ready request handling.

Kern

Kern is a minimalist web framework for Go, inspired by Python's Flask and Javalin (Java/Kotlin) and designed for developers who value simplicity and performance. It is built directly on top of the Go standard library's net/http package, leveraging the powerful new routing capabilities introduced in Go 1.22.

Kern is especially well suited for Go API servers, internal platform services, JSON backends, lightweight microservices, and teams that want stdlib-native HTTP semantics without framework bloat.

Built on Go 1.22's enhanced net/http router with zero external dependencies. This ensures future-proof compatibility and stability.

Why Kern?

  • 🚀 Go 1.22+ Routing: Leverages stdlib pattern matching for path parameters and wildcards.
  • ⚡ Context Pooling: Minimal allocations in hot paths using sync.Pool for optimal performance.
  • 🎯 Standard Patterns: No magic, just clean and idiomatic Go code.
  • 📦 Zero Dependencies: Core framework uses only the Go standard library.
  • 🔧 Middleware Ready: Built-in Logger, Recovery, and CORS middleware.
  • 🛡️ Production Ready: Graceful shutdown, timeouts, and TLS support out of the box.

Philosophy

Kern embraces minimalism without sacrificing functionality. It provides the essential building blocks for web applications while staying out of your way. You get:

  • Clean, predictable APIs.
  • Familiar HTTP semantics.
  • Easy-to-understand middleware patterns.
  • Performance-focused design.

Features

  • Routing: Support for all standard HTTP methods (GET, POST, PUT, DELETE, etc.) with group support.
  • Context: A powerful Context object for handling requests and responses efficiently.
  • Middleware: Easy-to-use middleware system with built-in options.
  • Data Binding: Helpers for JSON and XML binding.
  • Response Helpers: Simple methods for sending JSON, XML, HTML, and text responses.
  • Static Files: Serve static files with ease.

Best Fit Use Cases

  • Build REST and JSON APIs with predictable net/http behavior.
  • Migrate existing Go HTTP handlers into a structured framework gradually.
  • Run lightweight services where low allocations and clear middleware layering matter.
  • Ship production endpoints with request guards, sessions, timeouts, and security headers.

Examples

Kern includes ready-to-run examples in the examples directory:

ExampleDescription
basicSimple hello world with JSON responses
rest-apiFull CRUD REST API with route groups
middlewareCustom middleware patterns
observabilityRequestGuard deny metrics and session cookie failure signals
file-uploadHandle multipart file uploads
file-downloadDownload, stream, and serve static files
nested-routesNested route groups structure

Run any example:

go run examples/basic

Frequently Asked Questions

Is Kern good for API servers?

Yes. Kern is a strong fit for API servers that need low overhead, clear middleware composition, and full compatibility with Go's standard net/http ecosystem.

Does Kern replace net/http?

No. Kern builds on top of net/http and Go 1.22+ routing, so the request model stays familiar and interoperable.

Next Steps