Hical is a modern C++20/26 high-performance web framework built on Boost.Asio with a native HTTP/WebSocket stack, leveraging C++26 reflection and PMR memory pooling for maximum throughput.
English | 简体中文
- Native stack — picohttpparser HTTP parsing + self-developed WebSocket (RFC 6455), performance on par with Drogon/Cinatra
- C++26 Reflection — Automatic route registration + JSON serialization; C++20 macro fallback
- Coroutine async I/O —
asio::awaitable<T>+co_await, clean and efficient - PMR three-tier pool — Global synchronized / thread-local lock-free / request-level monotonic buffer
- High-performance routing — Static route O(1) hash lookup, sync fast path with zero coroutine frame overhead
- Onion middleware — Async + sync dual-mode middleware,
SyncMiddlewarewith zero coroutine frame - WebSocket — permessage-deflate compression, Origin whitelist, fragment reassembly
- SSL/TLS — Template-based
GenericConnection, compile-time branching - SO_REUSEPORT — Multi-acceptor, accept and I/O on same thread
- RouteGroup — Prefix grouping + group-level middleware + nesting
- CORS — Built-in cross-origin middleware with automatic preflight
- Cookie / Session — RFC 6265 + session fixation prevention + atomic migration
- Static files — ETag/304 + async I/O + PathCache
- Multipart — RFC 7578 file upload with DoS protection
- Logging — 6-level, async double-buffered, named channels, dynamic level management
- OpenAPI 3.0 — Auto-generate docs from macros, one-call Swagger UI setup
- Database middleware — Optional, coroutine connection pool + auto-transaction + slow query detection (Boost.MySQL)
#include "core/HttpServer.h"
using namespace hical;
int main()
{
HttpServer server(8080);
server.router().get("/", [](const HttpRequest&) -> HttpResponse {
return HttpResponse::json({{"message", "Hello, Hical!"}});
});
server.router().get("/users/{id}",
[](const HttpRequest& req) -> HttpResponse {
return HttpResponse::json({{"userId", req.param("id")}});
});
server.start();
}curl http://localhost:8080/
# {"message":"Hello, Hical!"}Full tutorial at docs/quickstart.md, more examples in examples/.
Native HTTP/WebSocket stack with performance on par with Drogon, Cinatra, and other leading C++ frameworks. See Performance Report.
# Docker one-click benchmark
docker compose -f docker-compose.bench.yml up| Dependency | Notes |
|---|---|
| C++20/26 | C++26 optional (reflection) |
| Boost >= 1.82 | Asio, System, JSON; DB middleware needs >= 1.85 |
| OpenSSL | Required |
| zlib | Required (WebSocket compression) |
| CMake >= 3.20 | Build system |
| GCC 14+ / Clang 20+ / MSVC 2022+ | Compiler |
# Linux / macOS
cmake -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build -j$(nproc)
ctest --test-dir build --output-on-failure
# Windows (MSYS2 MINGW64)
cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Release
cmake --build build
# Windows (MSVC + vcpkg)
cmake -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake
cmake --build build --config ReleaseOptional modules:
cmake -B build -DHICAL_WITH_DATABASE=ON ... # Database middleware
cmake -B build -DHICAL_WITH_OPENAPI=OFF ... # Disable OpenAPI
cmake -B build -DHICAL_ENABLE_REFLECTION=ON ...# C++26 Reflectionvcpkg install hical61-hicalfind_package(hical CONFIG REQUIRED)
target_link_libraries(my_app PRIVATE hical::hical_core)Download the Conan source package from GitHub Releases and export to local cache:
# Download & extract (replace VERSION with actual version)
curl -LO https://github.com/Hical61/Hical/releases/download/vVERSION/hical-VERSION-conan-src.tar.gz
tar xzf hical-VERSION-conan-src.tar.gz
# Export to local Conan cache
cd hical
conan export . --version=VERSION
conan install . --build=missingfind_package(hical REQUIRED)
target_link_libraries(my_app PRIVATE hical::hical_core)See Integration Guide for details.