Skip to content

AlkaidLab/intertwine-cpp-framework

Repository files navigation

AlkaidLab intertwine-cpp-framework

瑶光·捕梦网 C++ 框架

C++11 CMake License

面向服务端程序的 C++11 基础框架。它在 libhv 之上提供路由、中间件、HTTP/HTTPS/TCP/WebSocket 传输、文件发送、异步任务和常用工具组件。

公开 API 位于 intertwine::fw,CMake 包与链接目标为 intertwine_cpp_framework

中文文档 · English documentation

适用场景

能力 组件
HTTP 服务 ApplicationRouterContextMiddlewareChain
客户端通信 ITransportTransportFactory
文件发送 IFileTransferFileTransferFactory
并发控制 SupervisedThreadPoolLockfreeQueueSPSCQueueFlowController
基础工具 配置、日志、JWT、密码哈希、证书、JSON、ID 和时间处理

快速开始

git clone --recursive https://github.com/AlkaidLab/intertwine-cpp-framework.git
cd intertwine-cpp-framework
./build.sh --test

Windows:

git clone --recursive https://github.com/AlkaidLab/intertwine-cpp-framework.git
Set-Location intertwine-cpp-framework
.\build.ps1 -Test

构建脚本会准备 vcpkg 与 libhv 依赖。可按需要指定 vcpkg 或安装目录:

./build.sh --vcpkg-root ../vcpkg
./build.sh --install-dir ./out/install

使用方式

#include <intertwine/fw/Application.hpp>
#include <intertwine/fw/Context.hpp>
#include <intertwine/fw/Router.hpp>

namespace fw = intertwine::fw;

int main() {
    fw::Application app;
    fw::Router router;

    router.get("/hello", [](fw::Context& ctx) {
        ctx.json(200, "{\"message\":\"hello\"}");
    });

    app.mount(router);
    app.setPort(8080);
    return app.start();
}

CMake 集成

安装框架后,在项目中查找并链接 intertwine_cpp_framework

find_package(intertwine_cpp_framework REQUIRED)
target_link_libraries(your_target PRIVATE intertwine_cpp_framework)

若安装位置不在 CMake 的默认搜索路径中,配置项目时传入该前缀:

cmake -S . -B build -DCMAKE_PREFIX_PATH=/path/to/framework-install

作为子模块

git submodule add \
  https://github.com/AlkaidLab/intertwine-cpp-framework.git \
  third_party/intertwine-cpp-framework
git submodule update --init --recursive

文档

中文(默认):

English:

依赖

依赖由 vcpkg 构建流程解析;测试使用 GTest。

许可证

BSD 3-Clause License

About

瑶光·捕梦网 C++11 framework for HTTP/HTTPS, TCP, WebSocket, middleware, async tasks, and file transfer.

Topics

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors