🌟 New Features
- Type-Safe Middleware: Introduce
fluxo.Middleware to define middleware with automatic binding and validation, just like your handlers.
- Header Binding: Added support for the
header struct tag, allowing you to bind HTTP headers (e.g., Authorization, X-API-Key) directly into your request structs.
- Smart Swagger Merging: The OpenAPI generator now automatically merges request parameters and bodies from all handlers in a route chain.
- Variadic Routing: Updated routing methods (
GET, POST, etc.) to accept multiple handlers (...gin.HandlerFunc), aligning with Gin's native API.
🛠 Improvements & Fixes
- Robust Body Handling: Fixed an issue where reading the JSON body in middleware would cause an
EOF error in subsequent handlers.
- Swagger Reliability:
- Added protection against infinite recursion for circular references.
- Fixed documentation generation for nested slices.
- Stability: Fixed panics when using non-struct types as request bodies.
- Empty Requests: Improved handling for
DELETE and GET requests without bodies.
📚 New Examples
examples/todo_api: A full CRUD REST API.
examples/db_gorm: Integration with GORM (SQLite) and validation.
examples/middleware: Demonstration of type-safe middleware.
examples/auth_header: Bearer token authentication example.
📦 Upgrade
go get github.com/leviantech/fluxo@v0.2.0