$ show Corvusoft/restbed
restbed is a production-grade C++23 framework for building asynchronous RESTful HTTP and WebSocket servers. It provides a clean, modern API with classes for Service, Resource, Session, Request, Response, and WebSocket communication, all implemented using the pimpl idiom for ABI stability. The framework handles HTTP/1.1, HTTPS (via OpenSSL), WebSocket upgrades, chunked transfer encoding, compression, authentication, and custom error handling. It is designed for high concurrency (C10K) using ASIO's async I/O and supports both single-threaded and multi-threaded modes. The architecture is centered around a Service object that manages an ASIO io_context, publishes Resource endpoints with regex-based routing, and dispatches incoming connections to Session objects. Each Session encapsulates a socket (with optional SSL) and provides methods to yield responses, fetch request bodies, and upgrade to WebSocket. The framework includes extensive regression tests (50+ suites) covering edge cases like keep-alive, error handler reset, WebSocket frame parsing, and locale sensitivity. Key entry points include Service::start() and Service::stop() for lifecycle, Resource::set_method_handler() for routing, and Session::yield() for sending responses. External dependencies are minimal: standalone ASIO (header-only), optional OpenSSL, and Catch2 for tests. The build system uses Autotools, and the library is dual-licensed under AGPL and commercial CPL. Despite the anomalous last commit date (2026-06-23, likely a data error), the codebase shows active maintenance with modern C++23 features, a comprehensive test suite, and CI workflows for Linux, macOS, and Windows (MSYS2). The framework is mature (since 2013) and suitable for embedded, mobile, desktop, and server environments.
The LLM identified 4 files worth highlighting for reuse:
Provides a self-contained URI class with encoding/decoding using safe lookup tables, query parameter extraction, and strict validation. Can be extracted and used in any C++ project needing RFC 3986-compliant URI handling without external dependencies.
Offers a collection of efficient string operations: to_bytes, lowercase, split, join, replace, remove, and trim. The implementation avoids common pitfalls (e.g., infinite loops in replace) and uses modern C++23 features like std::ranges::to. Easily extractable for any C++ project.
Implements WebSocket frame parsing and composition per RFC 6455, including masking, extended lengths, and MSB checks. The parse() and to_bytes() functions are self-contained and could be reused in any C++ WebSocket implementation. Demonstrates careful bit-level handling and edge-case coverage.
Contains the error handler guard pattern (m_error_handler_invoked) that ensures at-most-once invocation per request, critical for keep-alive connections. This pattern is reusable in any server framework to prevent duplicate error responses. The keep-alive callback reset logic is also well-designed.