RESTinio is a header-oriented C++ library that embeds an asynchronous HTTP and WebSocket server built on standalone or Boost ASIO.
Overview
RESTinio is a C++17 library that provides an embedded HTTP and WebSocket server for applications that need to expose a REST API or similar interface from C++ code. It builds on a standalone ASIO distribution by default, with optional Boost ASIO support, and focuses on asynchronous request processing.
The library is mostly header-only but depends on the nodejs llhttp parser, which is not header-only. Handlers can defer responses and resume when data is ready, with HTTP pipelining and timeout control for stuck clients. Response builders cover chunked bodies and other patterns. Routing can follow an ExpressJS-like style or an experimental typesafe router, and multiple handlers can be chained similarly to middleware.
Features include query string handling, helpers for upload-related headers, sending files via sendfile on Unix and TransmitFile on Windows, deflate and gzip compression, TLS, basic WebSocket upgrade, and running on an external asio io_context with tunable acceptor and socket options.
A minimal example runs a server on the main thread and returns a fixed message, with access to the full request structure for custom logic. Documentation and issue tracking are maintained on GitHub.
Key features
- Async HTTP request handling
- HTTP pipelining and timeouts
- Express-like and typesafe routing
- Chained request handlers
- TLS and compression support
- WebSocket upgrade helper
- File send via OS primitives
- External asio io_context
Use cases
- Embedded REST API in a C++ program
- Async backends with deferred responses
- Small HTTP services without separate daemon