Skip to main content

Examples & Recipes

Learn GoFr by example. Each recipe is a working project you can clone and run.

$git clone https://github.com/gofr-dev/gofrCodespaces

Examples live under gofr/examples — pick any subfolder and run go run main.go.

HTTP Server

Basic REST API server with CRUD endpoints, Redis caching, and structured responses.

RESTGetting Started

gRPC Server

Build a gRPC service with protocol buffers, streaming, and automatic observability.

gRPCCommunication

Publisher

Publish messages to Kafka, Google Pub/Sub, NATS, or MQTT with a unified API.

Pub/SubMessaging

Subscriber

Subscribe to message topics with automatic offset management and error handling.

Pub/SubMessaging

HTTP Server with Redis

REST API backed by Redis for caching and session management.

RESTRedisDatabase

REST Handlers

Auto-generate CRUD endpoints by implementing the REST interface.

RESTGetting Started

Data Migrations

Run versioned schema migrations across MySQL, PostgreSQL, Redis, and MongoDB.

DatabaseMigrations

GraphQL API

Schema-first GraphQL with resolvers, playground, and built-in observability.

GraphQLCommunication

WebSocket

Real-time bidirectional communication with WebSocket support.

WebSocketCommunication

Cron Jobs

Schedule recurring tasks with cron expressions and automatic metrics.

BackgroundScheduling

Custom Metrics

Publish application-specific Prometheus metrics alongside built-in observability.

ObservabilityMetrics

HTTP Service Communication

Make inter-service HTTP calls with circuit breaker and retry support.

CommunicationResilience

Auth Middleware

Protect endpoints with Basic Auth, API Key, or OAuth middleware.

SecurityMiddleware

File Handling

Upload, download, and manage files with local, S3, GCS, or FTP backends.

FilesStorage

File Binding

Bind uploaded files directly to structs for type-safe file processing.

FilesData Binding

HTML Templates

Serve server-rendered HTML pages with Go template support.

TemplatesFrontend

CLI Application

Build command-line tools with subcommands, flags, and structured output.

CLITools