Skip to content

Hical61/Hical

hical

CI License: MIT C++ Standard Platform Boost GitHub release GitHub stars PRs Welcome

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 | 简体中文

Features

  • 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/Oasio::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, SyncMiddleware with 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)

Quick Start

#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/.

Performance

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

Requirements

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

Build

# 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 Release

Optional 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 Reflection

Installation

vcpkg (Recommended)

vcpkg install hical61-hical
find_package(hical CONFIG REQUIRED)
target_link_libraries(my_app PRIVATE hical::hical_core)

Conan

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=missing
find_package(hical REQUIRED)
target_link_libraries(my_app PRIVATE hical::hical_core)

See Integration Guide for details.

Documentation

License

MIT

About

Modern C++ web framework with C++26 reflection and PMR memory pools — built on Boost.Asio/Beast, coroutines, high performance

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors