Hical VS2022 快速上手 Demo

Hical VS2022 快速上手 Demo 一个最小化的 Hical HTTP Server 示例,VS2022 编译即可运行,访问即返回含中文的 JSON 响应。 环境要求 项目 版本要求 Visual Studio 2022 17.6+ (需勾选"C++桌面开发"工作负载) vcpkg 最新版 CMake >= 3.20 (VS2022 自带即可) 第一步:安装依赖 (vcpkg) 1 2 3 4 5 6 7 # 如果还没装 vcpkg git clone https://github.com/microsoft/vcpkg.git C:\vcpkg cd C:\vcpkg .\bootstrap-vcpkg.bat # 安装 Hical 所需依赖(x64-windows 默认 triplet) .\vcpkg install boost-asio boost-system boost-json boost-beast openssl zlib --triplet=x64-windows 第二步:获取 Hical 源码 1 2 git clone https://github.com/user/hical.git cd hical 第三步:CMake 构建 1 2 3 4 5 # 配置(替换为你的 vcpkg 实际路径,-DHICAL_BUILD_TESTS=OFF 跳过测试编译,加快构建速度) cmake -B build -A x64 -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake -DHICAL_BUILD_TESTS=OFF # 编译 cmake --build build --config Release 编译成功后,可执行文件位于: ...

May 12, 2026 · 4 min · 802 words

C++ 也能优雅写 Web?5 分钟用 Hical 搭建 REST API

C++ 也能优雅写 Web?5 分钟用 Hical 搭建 REST API 提到 C++ 写 Web 服务,你脑海中浮现的可能是满屏的模板报错、手动解析 HTTP 报文、以及回调嵌套到看不清缩进的代码。但在 2026 年,C++20 协程 + PMR 内存池 + C++26 反射的组合,已经让 C++ Web 开发体验发生了质变。本文用 Hical 框架带你体验:10 行代码启动 HTTP 服务器,40 行代码搞定完整 REST API。 10 行代码,启动 HTTP 服务器 1 2 3 4 5 6 7 8 9 10 11 12 13 #include "core/HttpServer.h" using namespace hical; int main() { HttpServer server(8080); server.router().get("/", [](const HttpRequest&) -> HttpResponse { return HttpResponse::ok("Hello, hical!"); }); server.start(); } 1 2 curl http://localhost:8080/ # Hello, hical! 没有工厂类,没有 Builder 链,没有 XML 配置。创建服务器、注册路由、启动 —— 三步完事。 ...

May 4, 2026 · 4 min · 666 words