{"id":18947667,"url":"https://github.com/asciphx/fabcc","last_synced_at":"2025-07-21T11:32:11.601Z","repository":{"id":41311945,"uuid":"509119460","full_name":"asciphx/FabCc","owner":"asciphx","description":"Asynchronous non-blocking dark magic for all-platform c++ web🌐 .No GC📵! LOW CODE💾!","archived":false,"fork":false,"pushed_at":"2025-06-29T04:37:15.000Z","size":4485,"stargazers_count":26,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-29T05:18:30.026Z","etag":null,"topics":["boost-context","coroutines","cpp","cross-platform","framework","http","http-server","low-code","media-server","modern-json","nodejs","oop","rust","webserver"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/asciphx.png","metadata":{"files":{"readme":"README-zh_CN.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-06-30T14:44:34.000Z","updated_at":"2025-06-29T04:37:18.000Z","dependencies_parsed_at":"2024-01-05T09:24:35.346Z","dependency_job_id":"26d6b678-be37-4e60-b509-52e739bc978b","html_url":"https://github.com/asciphx/FabCc","commit_stats":null,"previous_names":["asciphx/nod"],"tags_count":16,"template":false,"template_full_name":null,"purl":"pkg:github/asciphx/FabCc","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asciphx%2FFabCc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asciphx%2FFabCc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asciphx%2FFabCc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asciphx%2FFabCc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/asciphx","download_url":"https://codeload.github.com/asciphx/FabCc/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asciphx%2FFabCc/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266291665,"owners_count":23906310,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["boost-context","coroutines","cpp","cross-platform","framework","http","http-server","low-code","media-server","modern-json","nodejs","oop","rust","webserver"],"created_at":"2024-11-08T13:10:50.969Z","updated_at":"2025-07-21T11:32:11.593Z","avatar_url":"https://github.com/asciphx.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# FabCc(v1.0-UHD)\n[![license][license-badge]][license-link]\n![platform][supported-platforms-badge]\n[![release][release-badge]][release-link]\n\n[license-badge]: https://img.shields.io/badge/License-AGPL%20v3-gold.svg\n[license-link]: LICENSE\n[supported-platforms-badge]: https://img.shields.io/badge/platform-Win32%20|%20GNU/Linux%20|%20macOS%20|%20FreeBSD%20-maroon\n[release-badge]: https://img.shields.io/github/release/asciphx/FabCc.svg?style=flat-square\n[release-link]: https://github.com/asciphx/FabCc/releases\n灵感来自于其他c++知名web框架, FabCc的定位是一个网络框架, 其特点是低代码, 高性能, 强类型, 超标准, 最安全, 很牛逼。logo采用Nod的logo，设计来自命令与征服（CNC）。\n\n![FabCc](./static/logo.png)\n## [Eng](./README.md) | 简中\n\u003e 4月12日，超高清8k重制版到来。支持Gzip压缩网页降低流量消耗。修复各种bug，兼容了现代json、c++11，修复了keep-alive保活机制, 推出最强c++20无栈协程，以下是对比图。\n\u003e ![coroutine](./co%20vs%20Task.jpg)\n\n## 原创\n- 全面深度整合RBTree和时间轮（提升5%性能）封装的可取消定时器，同时修改底层协程用黑魔法管理其内存的释放，从而节省了内存\n- 支持c++20无栈协程，目前兼容了原项目的有栈非对称协程，并且是完美对接，几乎只需要少量的宏改动, 性能比有栈协程强了5%左右。\n- 增强型字段反射，例如`std::string_view sv = k(\u0026O::id);`将返回\"`O`.`id`\",(在C++14及更高版本可用constexpr修饰)。\n- 基于openssl的tcp客户端，由于是初步支持，尚且功能有限，大部分测试也可以通过。\n- 支持jsonc格式，以便兼容注释。不过，这只是在读取json文件的时候才会调用。\n- 拥有现代json的语法，以及对几乎所有的stl容器的全面兼容，还有全方位的宏来进行编译期的序列化与反序列化。\n- 支持MSVC上面的多核编译选项，使用`cmake --build ./build --config Release -j`既可并行编译。\n- 支持8K超高清视频播放功能，无卡顿，无延迟, 并且解锁超过4GB大小的视频的播放（亮点）。\n- 支持Gzip压缩功能，默认缓存了6秒，在CACHE_HTML_TIME_SECOND宏配置修改既可。之所以设置压缩比率为6，是因为个人认为这是效率与压缩比的最优解。\n- 全平台支持video或者是audio格式的range请求，可以随意点播跳转到任意的播放点, 例如wav,mp3,mp4,webm。并且可以设置是否允许下载，然后还支持暂停或者继续下载。\n- 从0-1设计具备借鉴于rust语言风格的box【[std::boxed::Box](https://doc.rust-lang.org/std/boxed/struct.Box.html)】，C++也可以用OOP方式编写。\n- body_parser用于处理multi_part文件上传，不单支持单文件支持自定义大小，甚至还可以支持多文件上传并结合了mmap的零拷贝的存储映射。\n- lexical_cast用于从字符串，字符视图到基本类型之间的互相转换，从0-1实现的是将header-only变为头文件源文件分离，并加速了编译速度。\n- router采用了动态路由技术，可以增删改查，目前还支持使用正则表达式，这是其他框架恰恰不具备的。\n- text是从0-1用于解决utf8的字符串存储，并且可以自行设定容量，每个容量都是针对utf8的，可以应对数据库中的varchar类型。\n- timer是从0-1用于解决c++没有javascript计时器的问题的，并且才用了头文件源文件分离，加速了编译速度。\n- 以上部件是个人技术实力的展示。当然，也有一些部件，其中并不完全是从0到1，但那些不是最重要的部件。\n\n## 特征\n- 基于epoll架构的全平台支持[windows下由wepoll实现]\n- 现在最低编译器版本支持到了c++11, 目前兼容了c++17的许多特性包括any, optional, string_view, 以及部分的扩展\n- 最少的第三方库，均以源文件形式存放项目中\n- 难以置信的编译速度，开发速度同时也得到提升\n- 支持网页版Postman，地址是127.0.0.1:8080/test.html\n- 可以对路由进行增删改查，动态路由参考【[lithium](https://github.com/matt-42/lithium)】迭代而成\n- 支持类似于无栈协程的非对称协程, 像python的生成器, 协程来自【[boost](https://github.com/boostorg/context)】\n- 拥有类似nodejs的api，写起来也像js, http解析器来自【[h2o](https://github.com/h2o/picohttpparser)】【[nodejs](https://github.com/nodejs/llhttp)】\n- 字符串映射的str_map【[beast](https://github.com/boostorg/beast),[crow](https://github.com/ipkn/crow)】\n- 静态文件缓存file_sptr【[libhttp](https://github.com/neithern/libhttp)】\n- 支持单元测试，文档请见【[coost](https://coostdocs.gitee.io/cn/co/unitest/)】\n- Json集成于【[coost](https://coostdocs.gitee.io/cn/co/json/)】, 并支持序列化与反序列化\n- zlib压缩来自【[zlib](https://github.com/madler/zlib)】\n- mman来自【[mman](https://code.google.com/archive/p/mman-win32/source/default/source)】\n- cache_file来自【[drogon](https://github.com/drogonframework/drogon/blob/master/lib/src/CacheFile.cc)】\n\n## 仍在开发中\n- [x] 动态路由\n- [x] gzip压缩\n- [x] body-parser的支持\n- [x] ssl证书\n- [ ] websocket\n- [x] 协程(c++11 ~ c++20)\n- [ ] udp服务端\n- [x] tcp客户端\n\n## 说明\n- 协程的原理图\n- ![yield](./yield.gif)\n- [示例](http://165.154.225.219:8080/)🚀\n- ![测试](./test.jpg)\n\n## 例子\n```c++\nusing namespace fc;\nint main() {\n  App app; app fc_app(web) fc_app(user);\n  app.file_type({ \"html\",\"htm\",\"ico\",\"css\",\"js\",\"json\",\"svg\",\"png\",\"jpg\",\"gif\",\"txt\",\"wasm\",\"mp4\",\"webm\",\"mp3\",\"wav\",\"aac\" })\n    .sub_api(\"/\", app.serve_file(\"static\")).set_keep_alive(4, 3, 2).set_use_max_mem(600.0).set_file_download(true);\n  app.default_route() = [](Req\u0026 req, Res\u0026 res)_ctx {\n    res.set_content_type(\"text/html;charset=UTF-8\", 23); res.set_status(404);\n    res.write_async_s([] {\n      char name[64]; gethostname(name, 64); Json x{ {\"header\", name} }; return mustache::load(\"404NotFound.html\").render(x);\n      }); co_return;//设置默认的路由\n  };\n  app[\"/redirect\"] = [](Req\u0026 req, Res\u0026 res)_ctx {\n    res.redirect(\"https://www.github.com\"); co_return;\n  };\n  app[\"/get_upload\"] = [](Req\u0026 req, Res\u0026 res)_ctx {\n    res.write_async([] {\n      auto f = fc::directory_iterator(fc::directory_ + fc::upload_path_); Json x;\n      std::set\u003cstd::string_view\u003e extentions = { \"mp4\", \"mp3\", \"webm\", \"wav\", \"mkv\" };\n      for (auto v : f) {\n        if (std::find(extentions.begin(), extentions.end(), fc::toLowerCase(v.ext)) != extentions.end()) {\n          x.push_back({ {\"name\",v.name.substr(fc::directory_.size())}, {\"size\",v.size} });\n        }\n      } return x;\n      }); co_return;//获取上传的文件列表\n  };\n  app[\"/read_file\"] = [](Req\u0026 req, Res\u0026 res)_ctx { res.write_async([] { Json x = json::read_file(\"test.json\"); return x; }); co_return; };\n  app[\"/json\"] = [](Req\u0026 req, Res\u0026 res)_ctx {\n    Json x; Book b{ \"ts\", Person{\"js\",6, Book{\"plus\" }, vec\u003cBook\u003e{ {\"1\", Person {\"sb\" }}, {\"2\", Person {\"sb\" }} }} };\n    b.person-\u003ebook = Book{ \"rs\", null, vec\u003cPerson\u003e{ {\"?\"}, {\"!\"} } }; x = b; res.write(x); co_return;//json请求\n  };\n  app[\"/serialization\"] = [](Req\u0026 req, Res\u0026 res)_ctx {\n    Json x = json::parse(R\"(\n    {\"name\":\"ts\",\"person\":{\"name\":\"js\",\"age\":33,\"book\":{\"name\":\"ojbk\",\"person\":{\"name\":\"fucker\",\"age\":0},\n    \"persons\":[{\"name\":\"stupid\",\"age\":1},{\"name\":\"idoit\",\"age\":2},{\"name\":\"bonkers\",\"age\":3,\"book\":{\"name\":\"sb\"}}]}}}\n    )\"); Book b = x.get\u003cBook\u003e(); b.person-\u003ebook-\u003epersons[2].name = \"wwzzgg\"; x = b; res.write(x.dump()); co_return;//反序列化与序列化\n  };\n  app[\"/api\"] = [](Req\u0026 req, Res\u0026 res)_ctx { res.write(res.app._print_routes()); co_return; };//返回路由列表\n  app.post(\"/api\") = [](Req\u0026 req, Res\u0026 res)_ctx {\n    BP bp(req, 1000); co_await bp.run(); std::string s;//支持上传的文件总大小1000MB\n    for (auto p : bp.params) {\n      s \u003c\u003c (p.key + \": \") \u003c\u003c p.value \u003c\u003c \", \";\n    }\n    s.pop_back(); s.pop_back(); res.write(s); co_return;\n  };\n  app[\"/del\"] = [](Req\u0026, Res\u0026 res)_ctx { res.app[\"/\"] = nullptr; res.write(\"主页的路由已被删除！！\"); co_return; };\n  app[\"/timer\"] = [](Req\u0026 req, Res\u0026 res)_ctx {\n    req.setTimeout([] { raise(SIGINT); }, 6000); res.write(\"关闭服务倒计时启动！\"); co_return;\n  };\n  //启动服务器，同样支持ipv6\n  app.http_serve(8080);\n}\n```\n\n### 构建（测试、示例）\n建议使用CMake进行源代码外构建。\n如果构建失败，请删除清理cmake缓存, 建议先删除build目录。\n`cmake -B build`后的额外编译选项。\n使用vcpkg `-DCMAKE_TOOLCHAIN_FILE=../vcpkg.cmake`\n使用llhttp解析器 `-DLLHTTP=1`\n使用openssl `-DOPENSSL=1`\n```\ncmake -B build -DLLHTTP=0 -DOPENSSL=0\ncmake --build ./build --config Release -j\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasciphx%2Ffabcc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fasciphx%2Ffabcc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasciphx%2Ffabcc/lists"}