Skip to main content
The Fuego framework provides a clean, intuitive API for building web applications and APIs in Go. This reference documents all public types, functions, and methods.

Quick Reference

Core Types

TypeDescription
AppMain application struct that manages routing, middleware, and server lifecycle
ContextRequest context passed to handlers with request/response methods
ConfigApplication configuration struct
HandlerFuncfunc(c *Context) error - Handler function signature
MiddlewareFuncfunc(next HandlerFunc) HandlerFunc - Middleware function signature
ProxyFuncfunc(c *Context) (*ProxyResult, error) - Proxy function signature

App Methods

MethodDescription
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

MethodDescription
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

MiddlewareDescription
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

FunctionDescription
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

FunctionStatus Code
BadRequest(msg)400
Unauthorized(msg)401
Forbidden(msg)403
NotFound(msg)404
Conflict(msg)409
InternalServerError(msg)500

Import

import "github.com/abdul-hamid-achik/fuego/pkg/fuego"

Basic Example

package main

import "github.com/abdul-hamid-achik/fuego/pkg/fuego"

func main() {
    app := fuego.New()
    
    app.Use(fuego.Logger())
    app.Use(fuego.Recover())
    
    app.Get("/", func(c *fuego.Context) error {
        return c.JSON(200, map[string]string{"message": "Hello, World!"})
    })
    
    app.Listen(":3000")
}
For Go documentation with full type details, see the pkg.go.dev documentation.