Build an HTTP service
In this guide, you'll build a complete HTTP service from scratch. You'll start with the basics of defining routes, then level up to type-safe handlers with dependency injection, request binding, and structured responses.
Stream with Server-Sent Events
Server-Sent Events (SSE) let you push real-time updates from the server to the client over a long-lived HTTP connection. The httpserver package has built-in support for SSE through the SseWriter type.
Serve a frontend
If you're building a single-page application (SPA), you can embed the frontend build into your Go binary and serve it directly from the httpserver.
Configure your server
The httpserver package provides flexible configuration options through YAML config files. All settings live under httpserver. where ` is the server name you pass to NewServer`.
Add middleware
The httpserver includes a built-in middleware chain and supports custom middleware at both the router and route-group level.
Authenticate requests
The github.com/gosoline-project/httpserver/auth package provides Gin-compatible middleware for common HTTP authentication patterns. You can attach auth middleware to the whole server, to a route group, or to selected routes.
Concurrency and connection pressure
The httpserver provides three complementary mechanisms to protect your service under load:
Real-world example
This guide walks through how two production applications — flink-admin and lakehouse-admin — use the httpserver package. These patterns demonstrate best practices for structuring a real application.
Chaos middleware
The httpserver includes an optional chaos middleware for resilience testing. When enabled, it randomly introduces failures to exercise client retry logic, circuit breakers, and timeout handling in non-production environments.