Flash
A fast, modular HTTP framework for Go — Fiber‑like ergonomics, Gin‑level reliability, 100% net/http
Install / Use
/learn @goflash/FlashREADME
Quick Start
package main
import (
"log"
"net/http"
"github.com/goflash/flash/v2"
"github.com/goflash/flash/v2/middleware"
)
func main() {
app := flash.New()
app.Use(middleware.Recover(), middleware.Logger())
// Easiest endpoint
app.ANY("/ping", func(c flash.Ctx) error {
return c.String(http.StatusOK, "pong")
})
// Path param with JSON response
app.GET("/hello/:name", func(c flash.Ctx) error {
return c.JSON(map[string]any{"hello": c.Param("name")})
})
log.Fatal(http.ListenAndServe(":8080", app))
}
More examples: goflash/examples
Features
- net/http compatible - Full compatibility with Go's standard library and HTTP/2
- Fast routing - High-performance routing with support for path parameters and route groups
- Ergonomic context - Clean API with helpers for common operations
- Composable middleware - Built-in middleware for logging, recovery, CORS, sessions, and more
- Static file serving - Serve static assets with flexible configuration
- Request binding - Bind JSON, form, query, and path parameters to structs
- Extensible - Add custom middleware and integrate with any slog-compatible logger
Middleware
Flash includes built-in middleware for common web application needs and supports external middleware packages.
Core Middleware
| Middleware | Purpose | | ----------- | --------------------------------------------------------------------------- | | Buffer | Response buffering to reduce syscalls and set Content-Length | | CORS | Cross-origin resource sharing with configurable policies | | CSRF | Cross-site request forgery protection using double-submit cookies | | Logger | Structured request logging with slog integration | | RateLimit | Rate limiting with multiple strategies (token bucket, sliding window, etc.) | | Recover | Panic recovery with configurable error responses | | RequestID | Request ID generation and correlation | | RequestSize | Request body size limiting for DoS protection | | Session | Session management with pluggable storage backends | | Timeout | Request timeout handling with graceful cancellation |
External Middleware
| Package | Description | Repository | | ------------- | ---------------------------------------------------- | --------------------------------------------------------------- | | OpenTelemetry | Distributed tracing and metrics integration | goflash/otel | | Validator | Request validation with go-playground/validator | goflash/validator | | Compression | Compression middleware for the GoFlash web framework | goflash/compression |
Installation
go get github.com/goflash/flash/v2
Core Concepts
Routing
- Register routes with methods or
ANY(). Group routes with shared prefix and middleware. Nested groups are supported and inherit parent prefix and middleware. - Custom methods: use
Handle(method, path, handler)for non-standard verbs. - Mount net/http handlers with
MountorHandleHTTP.
Routing patterns reference
Routing patterns and behavior follow julienschmidt/httprouter.
Context (Ctx)
flash.Ctx is a wrapper around http.ResponseWriter and *http.Request that provides convenient helpers for common operations:
- Request/Response Access - Direct access to underlying HTTP primitives
- Path & Query Parameters - Extract and parse URL parameters with type conversion
- Request Binding - Bind JSON, form, query, and path data to structs
- Response Writing - Send JSON, text, or raw responses with proper headers
- Context Management - Store and retrieve values in request context
For detailed method documentation, see the Go package documentation.
Request Binding
Flash provides helpers to bind request data to structs using json tags:
BindJSON- Bind JSON request bodyBindForm- Bind form data (URL-encoded or multipart)BindQuery- Bind query parametersBindPath- Bind path parametersBindAny- Bind from multiple sources with precedence: Path > Body > Query
type User struct {
ID int `json:"id"`
Name string `json:"name"`
}
app.POST("/users/:id", func(c flash.Ctx) error {
var user User
if err := c.BindAny(&user); err != nil {
return c.Status(400).JSON(map[string]string{"error": err.Error()})
}
return c.JSON(user)
})
net/http Interoperability
Flash is fully compatible with the standard library. You can:
- Mount any
http.Handlerusingapp.Mount(prefix, handler) - Register individual handlers with
app.HandleHTTP(method, path, handler) - Use Flash apps as
http.Handlerin other servers
// Mount existing handler
mux := http.NewServeMux()
mux.HandleFunc("/users", userHandler)
app.Mount("/api/", mux)
// Use Flash in standard server
mux := http.NewServeMux()
mux.Handle("/api/", http.StripPrefix("/api", app))
Examples
Runnable examples covering various use cases are available at goflash/examples.
For contrib-specific examples look at every specific middleware repository.
Benchmarks
Flash is benchmarked against Gin and Fiber across common web application scenarios. Performance is competitive with other major Go web frameworks.

Detailed benchmarks: goflash/benchmarks
Contributing
We welcome issues and PRs! Please read CONTRIBUTING.md.
<div align="center">
⭐ Star this repo if you find it useful!
<small>
📝 License: MIT | 📧 Support: Create an Issue
Battle tested in private productions. <br/> Released with ❤️ for the Go community.
</small> </div>