Skip to content
Projects

About

Go web framework on net/http: radix router, context API, and middleware. Optional Redis, Prometheus, and gRPC. Production-promising v2.1 — Go 1.27+.

Web & Apps

How these counts are measured

What you can do

  • Router — params (/users/:id), static suffixes after params, wildcards, groups, trailing-slash / 405 helpers
  • Middleware — Logger, Recovery, RequestID, Timeout, CORS, Gzip, Limiter, CSRF, Secure, JWT / JWTOptional, Metrics, Tenant, RBAC helpers, Idempotency-Key, Audit
  • Optional — Redis idempotency (middleware/redisidem), OpenTelemetry (middleware/otel), Prometheus, redislimit, gRPC
  • APIs — JSON bind/validate, httperr, cookies, SSE, WebSockets, file uploads (SafeUploadPath / FileFrom)

Measured star growth

in 24h
0
in 7 days
+1
in 15 days
Collecting history
in 1 month
Collecting history

Net star changes over overlapping periods, not daily totals. Missing measurements are left blank. Stars measure attention, not software quality.

README.md

Original

KVolt

KVolt

CI Go Reference License Go Version Release

KVolt is a Go web framework on net/http: a fast radix router, a familiar context API, and production middleware — with optional Redis, Prometheus, and gRPC as separate imports so the core stays lean.

v2.5.1 · Module: github.com/go-kvolt/kvolt/v2 · Requires Go 1.27+ · Changelog


Quick start

package main

import (
	"log"

	"github.com/go-kvolt/kvolt/v2"
	"github.com/go-kvolt/kvolt/v2/context"
	"github.com/go-kvolt/kvolt/v2/middleware"
)

func main() {
	app := kvolt.Default() // Recovery, Request-ID, 1MB body limit
	app.Use(middleware.Logger())

	app.GET("/ping", func(c *context.Context) error {
		return c.JSON(200, map[string]string{"message": "pong"})
	})

	// Run returns nil after a graceful shutdown; only a real error should exit non-zero.
	if err := app.Run(":8080"); err != nil {
		log.Fatal(err)
	}
}
go get github.com/go-kvolt/kvolt/[email protected]
go run .
# → http://localhost:8080/ping

Install

Library

go get github.com/go-kvolt/kvolt/[email protected]

CLI (scaffold + hot reload)

go install github.com/go-kvolt/kvolt/v2/cmd/[email protected]
kvolt new my-app
cd my-app && go mod tidy && go run ./cmd/api

If kvolt is not found: export PATH="$PATH:$(go env GOPATH)/bin"


Why KVolt

KVolt
Core net/http engine, radix router, Context helpers, graceful shutdown
Defaults kvolt.Default() — recovery, request ID, body size limit
Security CSRF, Secure headers, JWT, BasicAuth/APIKey, trusted-proxy ClientIP, safe redirects/uploads
Batteries Config, DI, validation, sessions, cache, queue, scheduler, OpenAPI/Scalar
Optional deps Redis cache/queue, Prometheus, gRPC — imported only when you need them

Compared to Gin/Echo/Fiber: similar routing ergonomics, with more built-ins in-tree and heavier integrations kept out of the default import graph.


Features

  • Router — params (/users/:id), static suffixes after params, wildcards, groups, trailing-slash / 405 helpers
  • Middleware — Logger, Recovery, RequestID, Timeout, CORS, Gzip, Limiter, CSRF, Secure, JWT / JWTOptional, Metrics, Tenant, RBAC helpers, Idempotency-Key, Audit
  • Optional — Redis idempotency (middleware/redisidem), OpenTelemetry (middleware/otel), Prometheus, redislimit, gRPC
  • APIs — JSON bind/validate, httperr, cookies, SSE, WebSockets, file uploads (SafeUploadPath / FileFrom)
  • Docs — OpenAPI from routes + Scalar UI
  • Jobs — in-memory queue; Redis at-least-once queue (pkg/queue/redis)
  • Cache — sharded memory store; Redis store (pkg/cache/redis)
  • gRPC — grpc.Attach / RunDual alongside HTTP
  • DX — kvolt CLI (new scaffolds health + OpenAPI + tenant stub), templates, pkg/test / pkg/testkit

Full list and guides: Documentation


Examples

Example Description
example/full_app Middleware, JWT, queue, Prometheus, OpenAPI
example/tenant_app Tenant + RBAC + Idempotency + Audit
example/queue_app Background jobs
example/grpc_app HTTP + gRPC dual serve

Documentation


Binding example

app.POST("/users", func(c *context.Context) error {
	var u struct {
		Name  string `json:"name" validate:"required"`
		Email string `json:"email" validate:"required,email"`
	}
	if err := c.Bind(&u); err != nil {
		return err // maps to JSON via httperr / WriteHandlerError
	}
	return c.JSON(201, u)
})

Development

go test ./...
./scripts/local10.ps1   # fmt, vet, race, soak, fuzz (needs gcc on Windows)
./scripts/bench.ps1     # microbenchmarks

See CONTRIBUTING.md.


Benchmarks

Methodology + live HTTP comparison: docs/benchmarks.md.

Microbenchmarks (in-process)

./scripts/bench.ps1

Sample (go1.27.3, Windows/amd64, Lenovo Yoga Slim 7 14IMH9, Intel Core Ultra 7 155H) — run on your machine for authoritative numbers:

Benchmark ns/op allocs/op ≈ ops/sec
BenchmarkEngine_Ping ~114 2 ~8.7M
BenchmarkEngine_PingParallel ~50 2 ~20M
BenchmarkEngine_JSON ~2.2µs 6 ~460k
BenchmarkEngine_Param ~407 2 ~2.5M
BenchmarkEngine_DefaultPing ~1.3µs 9 ~780k
BenchmarkRouter_Static ~16 0 ~63M
BenchmarkRouter_Param ~50 1 ~20M

Live HTTP (GET /ping, median of 10 rounds)

Same laptop/CPU. Bombardier, 125 conn, 10s. Full table + how to reproduce: docs/benchmarks.md.

Framework Engine Median RPS
Fiber fasthttp ~87k
KVolt net/http ~81k
Gin net/http ~70k
stdlib net/http ~68k
Echo net/http ~67k
Chi net/http ~66k
cd benchmarks/live; ./run10.ps1

API Stability & Semantic Versioning

KVolt strictly adheres to Semantic Versioning (SemVer 2.0.0):

  • v2.x.y: All minor (v2.x.0) and patch (v2.x.y) updates maintain complete backward compatibility. No public APIs will be removed or broken within v2.
  • Breaking Changes: Any breaking architectural change will only occur with a major version increment (v3.0.0) and an explicit deprecation timeline.
  • Security & Quality: CI runs the test suite with the race detector, govulncheck, gosec static analysis, golangci-lint, and fuzz tests on every push and pull request, and fails when library test coverage drops below 90%. Run ./scripts/cover.ps1 for current coverage numbers.

License

MIT

Created & maintained by Kaviraj Mani

Explore related projects

Loading…