HCS Documentation#
HCS is an HTTP library for OCaml 5+ built on Eio. It provides HTTP/1.1, HTTP/2, and WebSocket support for both clients and servers.
Getting Started#
New to HCS? Start here:
- Installation - Set up HCS in your project
- Your First Server - Build a simple HTTP server
- Your First Client - Make HTTP requests
Guides#
Learn the core concepts:
- Request Lifecycle - How requests flow through HCS
- Routing - Map URLs to handlers with path parameters
- Plug System - Compose middleware pipelines
- Responses - Build responses and stream data
- Error Handling - Handle errors gracefully
HTTP Client#
Using HCS as an HTTP client:
- Basic Requests - GET, POST, headers, and bodies
- HTTP/2 - HTTP/2 multiplexing and server push
- Connection Pooling - Reuse connections efficiently
- TLS Configuration - Certificates and security settings
Real-time#
Build real-time applications:
- WebSocket - Bidirectional communication
- Server-Sent Events - Server-to-client streaming
- PubSub - Topic-based message broadcasting
- Channels - Multiplexed WebSocket conversations
Plugs#
The middleware system:
- Overview - What plugs are and how they compose
- Writing Plugs - Create custom middleware
Recipes#
Common patterns and solutions:
- Authentication - Sessions, basic auth, CSRF
- Rate Limiting - Protect against abuse
- CORS - Cross-origin resource sharing
- Static Files - Serve files from disk
- JSON APIs - Content negotiation and JSON responses