Type-Safe HTTP Framework for Go. Define Types. Derive Everything.

Build APIs where struct types are the single source of truth. Validation, OpenAPI 3.1.0 specs, error contracts, and interactive docs all generated automatically from your Go types — on a stdlib foundation.

Getting Started
import "github.com/zoobz-io/rocco"

type CreateOrderInput struct {
    CustomerID string  `json:"customer_id" description:"Customer UUID"`
    Total      float64 `json:"total" description:"Order total"`
}

type OrderOutput struct {
    ID        string    `json:"id"`
    Status    string    `json:"status"`
    CreatedAt time.Time `json:"created_at"`
}

// Define once — validation, OpenAPI, and docs derived automatically
engine := rocco.New()

rocco.POST[CreateOrderInput, OrderOutput]("/orders",
    func(req *rocco.Request[CreateOrderInput]) (OrderOutput, error) {
        body := req.Body() // Typed, validated
        return OrderOutput{
            ID:        uuid.New().String(),
            Status:    "created",
            CreatedAt: time.Now(),
        }, nil
    },
).WithSuccessStatus(201).
  WithErrors(ErrInvalidOrder, ErrCustomerNotFound).
  Register(engine)

// OpenAPI at /openapi, interactive docs at /docs
engine.Run(":8080")
96%Test Coverage
A+Go Report
MITLicense
1.24.0+Go Version
v0.1.20Latest Release

Why Rocco?

One type definition drives validation, documentation, and error contracts.

Contract-First by Default

Struct types are the single source of truth. OpenAPI schemas, validation rules, and error contracts all derived — never out of sync.

Automatic OpenAPI 3.1.0

Specs generated at handler registration. Served at /openapi with interactive docs at /docs. No separate schema files.

Built-In Validation

Opt-in via Validatable interface. Struct tag constraints and cross-field checks run before your handler sees the data.

Stdlib Foundation

Built on Go 1.22+ http.ServeMux with native path parameters. No heavy external router — direct access to the underlying mux.

First-Class SSE Streaming

Server-Sent Events with typed Stream[T] interface. Real-time data flows are a core feature, not an afterthought.

Declared Error Contracts

Handlers must declare their errors. Undeclared errors log warnings and return 500 — no silent failures in production.

Capabilities

Type-safe handlers, automatic documentation, authentication, and streaming on a stdlib foundation.

FeatureDescriptionLink
Type-Safe HandlersGeneric handlers with compile-time input/output checking. NoBody for bodyless requests, path and query parameters.Handlers
Error HandlingSentinel errors with structured JSON responses. Error types declared per handler, auto-documented in OpenAPI.Errors
AuthenticationBuilt-in identity extraction, scope-based authorization, and role-based access control middleware.Authentication
OpenAPI GenerationSchema generation from types at registration time. Customizable with descriptions, examples, and overrides.OpenAPI
Server-Sent EventsTyped Stream[T] interface for real-time data. Heartbeats, reconnection, and graceful shutdown built in.Streaming
Lifecycle EventsCapitan signals for request received, handler executing, errors, and completion. Full observability hooks.Observability

Articles

Browse the full rocco documentation.

OverviewType-safe HTTP framework for Go with automatic OpenAPI generation

Learn

QuickstartGet started with rocco in 5 minutes
Core ConceptsUnderstand handlers, requests, responses, and parameters
ArchitectureHow rocco processes requests internally

Guides

HandlersDeep dive into handler configuration and patterns
Error HandlingError patterns, sentinel errors, and custom error types
Authentication & AuthorizationIdentity extraction, scopes, roles, and usage limits
OpenAPI GenerationSchema generation, tags, and validation mapping
Best PracticesSecurity, performance, and production patterns
Streaming (SSE)Server-Sent Events for real-time data streaming

Cookbook

CRUD APIComplete CRUD API example with all patterns
Authentication PatternsAuth0, session-based OAuth, JWT, API keys, and multi-auth implementations
ObservabilityLogging, metrics, and tracing with capitan
Real-time PatternsRecipes for building real-time features with SSE

Reference

API ReferenceComplete API documentation for rocco
Errors ReferenceComplete reference for error types and details
Events ReferenceComplete reference for event signals and field keys