Powerful Features
go-wolf combines performance, developer experience, and production readiness with a comprehensive feature set designed for modern web development.
Advanced Routing Engine
High-performance trie-based router with static and dynamic route matching, parameter extraction, and wildcard support.
// Static and dynamic routes
app.Get("/users", getUsersHandler)
app.Get("/users/:id", getUserHandler)
app.Post("/users", createUserHandler)
// Route groups with middleware
v1 := app.Group("/api/v1")
v1.Use(authMiddleware)
{
v1.Get("/profile", getProfileHandler)
v1.Put("/profile", updateProfileHandler)
}
// Wildcard routes
app.Get("/static/*filepath", staticHandler)
Rich Context API
Comprehensive context abstraction with helpers for binding, validation, and response handling.
func handler(c *wolf.Context) error {
// Get path parameters
id := c.Param("id")
// Query parameters
page := c.Query("page", "1")
limit := c.QueryInt("limit", 10)
// Bind JSON request body
var user User
if err := c.BindJSON(&user); err != nil {
return c.JSON(400, wolf.Map{"error": "Invalid JSON"})
}
// Validate struct
if err := c.Validate(&user); err != nil {
return c.JSON(400, wolf.Map{"error": err.Error()})
}
// Return JSON response
return c.JSON(200, wolf.Map{
"user": user,
"id": id,
})
}
Flexible Middleware
Powerful middleware system with built-in common middleware and support for custom middleware chains.
// Custom authentication middleware
func AuthMiddleware() wolf.HandlerFunc {
return func(c *wolf.Context) error {
token := c.Header("Authorization")
if token == "" {
return c.JSON(401, wolf.Map{"error": "Unauthorized"})
}
// Verify token logic here
if !isValidToken(token) {
return c.Abort(401, "Invalid token")
}
// Store user in context
c.Set("user", user)
return c.Next()
}
}
// Usage
app.Use(AuthMiddleware())
app.Use(wolf.Logger())
app.Use(wolf.Recovery())
app.Use(wolf.CORS())
Error Handling
Centralized error handling with custom error types, stack traces in development, and recovery middleware.
// Global error handler
app.ErrorHandler = func(c *wolf.Context, err error) error {
if e, ok := err.(*wolf.HTTPError); ok {
return c.JSON(e.Code, wolf.Map{
"error": e.Message,
"code": e.Code,
})
}
// Log internal errors
log.Printf("Internal error: %v", err)
return c.JSON(500, wolf.Map{
"error": "Internal server error",
})
}
// Custom error types
func handler(c *wolf.Context) error {
user, err := getUserByID(c.Param("id"))
if err != nil {
return wolf.NewHTTPError(404, "User not found")
}
return c.JSON(200, user)
}
Extreme Performance
Zero allocation routing, memory pooling, and optimized hot paths for maximum throughput.
// Benchmark results comparison
BenchmarkWolf-8 1000000 1200 ns/op 0 B/op 0 allocs/op
BenchmarkGin-8 800000 1580 ns/op 0 B/op 0 allocs/op
BenchmarkFiber-8 900000 1350 ns/op 0 B/op 0 allocs/op
BenchmarkEcho-8 750000 1680 ns/op 0 B/op 0 allocs/op
// Memory pooling
var contextPool = sync.Pool{
New: func() interface{} {
return &Context{}
},
}
// Zero allocation routing
func (r *Router) lookup(method, path string) (*Route, Params) {
// Highly optimized trie-based routing
// No allocations in hot path
}
Core Capabilities
Everything you need to build production-ready web applications and APIs.
HTTP Server
- Built on net/http for compatibility
- Graceful shutdown support
- Auto TLS with Let's Encrypt
- Connection keep-alive management
Security
- CORS middleware
- Rate limiting
- Request timeout
- Panic recovery
Data Binding
- JSON binding and validation
- Form data parsing
- Query parameter extraction
- Custom validation rules
Response Types
- JSON responses
- HTML template rendering
- File serving
- Raw bytes and strings
Configuration
- Environment-based config
- Flexible logging
- Debug mode
- Custom error handlers
Extensibility
- Plugin system
- Custom renderers
- WebSocket support
- gRPC proxying
Performance First
Benchmarked against popular Go frameworks with superior performance metrics.
Requests/sec
High-throughput request handling with optimized routing
Response Time
Ultra-low latency with zero allocation hot paths
Memory Usage
Efficient memory management with object pooling
Test Coverage
Comprehensive test suite ensuring reliability