httpsrv is a lightweight, net/http-native web framework for Go. It offers a Fiber v3-style routing surface (App/Router/Ctx/Handler) implemented from scratch over the standard library.
- net/http-native — the typical handler is
func(Ctx) error; a stdlibhttp.Handler(e.g.http.HandlerFunc) is also accepted, so handlers interoperate directly with the Go ecosystem - Radix-tree routing — per-method trees,
{param}and{*catchAll}path values, case-sensitive, static segments beat params beat catch-alls (order-independent) - Middleware & Groups —
Usewith fiber v3-style middleware (func(Ctx) error+c.Next()), global or prefix-scoped;Group(prefix)for prefix sharing - Static files —
middleware/staticexposesNew(root, ...Config)returning anhttpsrv.Handler:app.Get("/*", static.New("./public"))orapp.Get("/*", static.New(".", static.Config{FS: embedFS})); directory or embedded filesystem - Template rendering —
html/templateparsed once,Ctx.Render(name, bind, layouts...) - i18n (opt-in) — flat locale message store,
AcceptLanguagemiddleware (BCP-47 viax/text) - Compression (opt-in) —
middleware/compressexposesNew(config...)(gzip/brotli byAccept-Encoding, brotli preferred) - Graceful server — safe default timeouts,
Shutdown(ctx)
Full guide (English): doc/ — Quick Start · Routing · Groups · Middleware · Server · Static · Ctx & Handler · Render · i18n · Examples · Index
中文文档:doc/zh-CN/
go get -u github.com/hooto/httpsrv/v2package main
import (
"github.com/hooto/httpsrv/v2"
)
func main() {
app := httpsrv.New()
app.Get("/", func(c httpsrv.Ctx) error {
return c.SendString("hello httpsrv")
})
app.Run(":8080")
}Run and try it:
$ go run .
$ curl http://localhost:8080/
hello httpsrvSee examples/ for runnable programs (hello, i18n, groups/static/render).
httpsrv keeps the core concise. Some recommended third-party libraries:
- mysqlgo - MySQL client
- pgsqlgo - PostgreSQL client
- redisgo - Redis client
- kvgo - Embedded Key-Value database
- hlog4g - Logging library
- hini4g - INI configuration file parsing
- hflag4g - Command line argument handling
- hlang4g - i18n internationalization
- hcaptcha4g - CAPTCHA generation
More Go ecosystem libraries: awesome-go
- Go Version: 1.26 or higher
- Recommended Systems: Linux, Unix, or macOS
httpsrv's API surface (App/Router/Ctx/Handler) is inspired by Fiber v3 — a from-scratch implementation over net/http with no dependency on fiber.