App
Application lifecycle, routing, and server management
Context
Request handling, response methods, and context storage
Config
Configuration options and environment variables
Middleware
Built-in middleware and custom middleware patterns
Proxy
Request interception and routing control
Errors
HTTP error types and error handling helpers
OpenAPI
Automatic OpenAPI specification generation
CLI Reference
Command-line interface and code generation
Quick Reference
Core Types
| Type | Description |
|---|---|
App | Main application struct that manages routing, middleware, and server lifecycle |
Context | Request context passed to handlers with request/response methods |
Config | Application configuration struct |
HandlerFunc | func(c *Context) error - Handler function signature |
MiddlewareFunc | func(next HandlerFunc) HandlerFunc - Middleware function signature |
ProxyFunc | func(c *Context) (*ProxyResult, error) - Proxy function signature |
App Methods
| Method | Description |
|---|---|
fuego.New(opts...) | Create a new App with optional configuration |
app.Get/Post/Put/Delete(pattern, handler) | Register route handlers |
app.Use(middleware) | Add global middleware |
app.Group(pattern, fn) | Create a route group with shared middleware |
app.Static(path, dir) | Serve static files |
app.ServeOpenAPI(opts) | Enable OpenAPI spec and Swagger UI |
app.Listen(addr) | Start the HTTP server |
app.Shutdown(ctx) | Gracefully shutdown the server |
Context Methods
| Method | Description |
|---|---|
c.Param(name) | Get URL parameter |
c.Query(name) | Get query string value |
c.Header(name) | Get request header |
c.Bind(&struct) | Parse JSON body into struct |
c.JSON(status, data) | Return JSON response |
c.HTML(status, html) | Return HTML response |
c.Redirect(status, url) | Redirect to URL |
c.Set/Get(key, value) | Context storage |
Built-in Middleware
| Middleware | Description |
|---|---|
Logger() | Request/response logging |
Recover() | Panic recovery |
CORS() | Cross-origin resource sharing |
RequestID() | Add unique request IDs |
Timeout(duration) | Request timeout |
BasicAuth(validator) | HTTP Basic authentication |
Compress() | Response compression |
RateLimiter(max, window) | Rate limiting |
SecureHeaders() | Security headers |
Proxy Actions
| Function | Description |
|---|---|
Continue() | Continue with normal routing |
Redirect(url, code) | Redirect to another URL |
Rewrite(path) | Internal URL rewrite |
ResponseJSON(code, data) | Return JSON response immediately |
ResponseHTML(code, html) | Return HTML response immediately |
Error Helpers
| Function | Status Code |
|---|---|
BadRequest(msg) | 400 |
Unauthorized(msg) | 401 |
Forbidden(msg) | 403 |
NotFound(msg) | 404 |
Conflict(msg) | 409 |
InternalServerError(msg) | 500 |
Import
Basic Example
For Go documentation with full type details, see the pkg.go.dev documentation.