[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-95898":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":9,"totalLinesOfCode":9,"stars":12,"forks":13,"watchers":14,"openIssues":14,"contributorsCount":9,"subscribersCount":14,"size":14,"stars1d":14,"stars7d":14,"stars30d":14,"stars90d":14,"forks30d":14,"starsTrendScore":14,"compositeScore":15,"rankGlobal":9,"rankLanguage":9,"license":9,"archived":16,"fork":16,"defaultBranch":17,"hasWiki":16,"hasPages":16,"topics":18,"createdAt":9,"pushedAt":9,"updatedAt":25,"readmeContent":26,"aiSummary":27,"trendingCount":14,"starSnapshotCount":14,"syncStatus":28,"lastSyncTime":9,"discoverSource":29},95898,"drogon","drogonframework\u002Fdrogon","drogonframework","Drogon: A C++14\u002F17\u002F20 based HTTP web application framework running on Linux\u002FmacOS\u002FUnix\u002FWindows",null,"https:\u002F\u002Fgithub.com\u002Fdrogonframework\u002Fdrogon","C++",14243,1377,0,44.42,false,"main",[19,20,21,22,5,23,24],"linux","http-framework","http-server","http","non-blocking-io","asynchronous-programming","2026-09-21 02:04:28","![](https:\u002F\u002Fgithub.com\u002Fan-tao\u002Fdrogon\u002Fwiki\u002Fimages\u002Fdrogon-white17.jpg)\n\n[![Build Status](https:\u002F\u002Fgithub.com\u002Fdrogonframework\u002Fdrogon\u002Factions\u002Fworkflows\u002Fcmake.yml\u002Fbadge.svg?branch=master)](https:\u002F\u002Fgithub.com\u002Fdrogonframework\u002Fdrogon\u002Factions)\n[![Conan Center](https:\u002F\u002Fimg.shields.io\u002Fconan\u002Fv\u002Fdrogon)](https:\u002F\u002Fconan.io\u002Fcenter\u002Frecipes\u002Fdrogon)\n[![Join the telegram group at https:\u002F\u002Ft.me\u002Fjoinchat\u002F_mMNGv0748ZkMDAx](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FTelegram-2CA5E0?style=flat&logo=telegram&logoColor=white)](https:\u002F\u002Ft.me\u002Fjoinchat\u002F_mMNGv0748ZkMDAx)\n[![Join our Discord](https:\u002F\u002Fdcbadge.vercel.app\u002Fapi\u002Fserver\u002F3DvHY6Ewuj?style=flat)](https:\u002F\u002Fdiscord.gg\u002F3DvHY6Ewuj)\n[![Docker image](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FDocker-image-blue.svg)](https:\u002F\u002Fcloud.docker.com\u002Fu\u002Fdrogonframework\u002Frepository\u002Fdocker\u002Fdrogonframework\u002Fdrogon)\n\nEnglish | [简体中文](.\u002FREADME.zh-CN.md) | [繁體中文](.\u002FREADME.zh-TW.md)\n\n### Overview\n\n**Drogon** is a C++17\u002F20 based HTTP application framework. Drogon can be used to easily build various types of web application server programs using C++. **Drogon** is the name of a dragon from the American TV series *Game of Thrones*, which I really enjoy.\n\nDrogon is a cross-platform framework, It supports Linux, macOS, FreeBSD, OpenBSD, HaikuOS, and Windows. Its main features are as follows:\n\n* Use a non-blocking I\u002FO network lib based on epoll (kqueue under macOS\u002FFreeBSD) to provide high-concurrency, high-performance network IO, please visit the [TFB Tests Results](https:\u002F\u002Fwww.techempower.com\u002Fbenchmarks\u002F#section=data-r19&hw=ph&test=composite) for more details;\n* Provide a completely asynchronous programming mode;\n* Support HTTP 1.0\u002F1.1 (server side and client side);\n* Based on template, a simple reflection mechanism is implemented to completely decouple the main program framework, controllers and views.\n* Support cookies and built-in sessions;\n* Support back-end rendering, the controller generates the data to the view to generate the HTML page. Views are described by CSP template files, C++ codes are embedded into HTML pages through CSP tags. And the drogon command-line tool automatically generates the C++ code files for compilation;\n* Support view page dynamic loading (dynamic compilation and loading at runtime);\n* Provide a convenient and flexible routing solution from the path to the controller handler;\n* Support filter chains to facilitate the execution of unified logic (such as login verification, Http Method constraint verification, etc.) before handling HTTP requests;\n* Support HTTPS (based on OpenSSL);\n* Support WebSocket (server side and client side);\n* Support JSON format request and response, very friendly to the Restful API application development;\n* Support file download and upload;\n* Support gzip, brotli compression transmission;\n* Support pipelining;\n* Provide a lightweight command line tool, drogon_ctl, to simplify the creation of various classes in Drogon and the generation of view code;\n* Support non-blocking I\u002FO based asynchronously reading and writing database (PostgreSQL and MySQL(MariaDB) database);\n* Support asynchronously reading and writing sqlite3 database based on thread pool;\n* Support Redis with asynchronous reading and writing;\n* Support ARM Architecture;\n* Provide a convenient lightweight ORM implementation that supports for regular object-to-database bidirectional mapping;\n* Support plugins which can be installed by the configuration file at load time;\n* Support AOP with built-in joinpoints.\n* Support C++ coroutines\n\n## A very simple example\n\nUnlike most C++ frameworks, the main program of the drogon application can be kept clean and simple. Drogon uses a few tricks to decouple controllers from the main program. The routing settings of controllers can be done through macros or configuration file.\n\nBelow is the main program of a typical drogon application:\n\n```c++\n#include \u003Cdrogon\u002Fdrogon.h>\n\nusing namespace drogon;\n\nint main()\n{\n    app().setLogPath(\".\u002F\")\n         .setLogLevel(trantor::Logger::kWarn)\n         .addListener(\"0.0.0.0\", 80)\n         .setThreadNum(16)\n         .enableRunAsDaemon()\n         .run();\n}\n```\n\nIt can be further simplified by using configuration file as follows:\n\n```c++\n#include \u003Cdrogon\u002Fdrogon.h>\n\nusing namespace drogon;\n\nint main()\n{\n    app().loadConfigFile(\".\u002Fconfig.json\").run();\n}\n```\n\nDrogon provides some interfaces for adding controller logic directly in the `main()` function, for example, user can register a handler like this in Drogon:\n\n```c++\napp().registerHandler(\"\u002Ftest?username={name}\",\n                    [](const HttpRequestPtr& req,\n                       std::function\u003Cvoid (const HttpResponsePtr &)> &&callback,\n                       const std::string &name) -> void\n                    {\n                        Json::Value json;\n                        json[\"result\"] = \"ok\";\n                        json[\"message\"] = \"hello, \" + name;\n                        HttpResponsePtr resp = HttpResponse::newHttpJsonResponse(json);\n                        callback(resp);\n                    },\n                    {Get,\"LoginFilter\"});\n```\n\nWhile such interfaces look intuitive, they are not suitable for complex business logic scenarios. Assuming there are tens or even hundreds of handlers that need to be registered in the framework, isn't it a better practice to implement them separately in their respective classes? So unless your logic is very simple, we don't recommend using above interfaces. Instead, we can create an `HttpSimpleController` as follows:\n\n```c++\n\u002F\u002F\u002F The TestCtrl.h file\n#pragma once\n#include \u003Cdrogon\u002FHttpSimpleController.h>\n\nusing namespace drogon;\n\nclass TestCtrl : public HttpSimpleController\u003CTestCtrl>\n{\npublic:\n    void asyncHandleHttpRequest(const HttpRequestPtr& req, std::function\u003Cvoid (const HttpResponsePtr &)> &&callback) override;\n    PATH_LIST_BEGIN\n    PATH_ADD(\"\u002Ftest\",Get);\n    PATH_LIST_END\n};\n\n\u002F\u002F\u002F The TestCtrl.cc file\n#include \"TestCtrl.h\"\n\nvoid TestCtrl::asyncHandleHttpRequest(const HttpRequestPtr& req,\n                                      std::function\u003Cvoid (const HttpResponsePtr &)> &&callback)\n{\n    \u002F\u002F write your application logic here\n    HttpResponsePtr resp = HttpResponse::newHttpResponse();\n    resp->setBody(\"\u003Cp>Hello, world!\u003C\u002Fp>\");\n    resp->setExpiredTime(0);\n    callback(resp);\n}\n```\n\n**Most of the above programs can be automatically generated by the command line tool `drogon_ctl` provided by drogon** (The command is `drogon_ctl create controller TestCtrl`). All the user needs to do is add their own business logic. In the example, the controller returns a `Hello, world!` string when the client accesses the `http:\u002F\u002Fip\u002Ftest` URL.\n\nFor JSON format response, we create the controller as follows:\n\n```c++\n\u002F\u002F\u002F The header file\n#pragma once\n\n#include \u003Cdrogon\u002FHttpSimpleController.h>\n\nusing namespace drogon;\n\nclass JsonCtrl : public HttpSimpleController\u003CJsonCtrl>\n{\n  public:\n    void asyncHandleHttpRequest(const HttpRequestPtr &req, std::function\u003Cvoid(const HttpResponsePtr &)> &&callback) override;\n    PATH_LIST_BEGIN\n    \u002F\u002F list path definitions here;\n    PATH_ADD(\"\u002Fjson\", Get);\n    PATH_LIST_END\n};\n\n\u002F\u002F\u002F The source file\n#include \"JsonCtrl.h\"\n\nvoid JsonCtrl::asyncHandleHttpRequest(const HttpRequestPtr &req,\n                                      std::function\u003Cvoid(const HttpResponsePtr &)> &&callback)\n{\n    Json::Value ret;\n    ret[\"message\"] = \"Hello, World!\";\n    HttpResponsePtr resp = HttpResponse::newHttpJsonResponse(ret);\n    callback(resp);\n}\n```\n\nLet's go a step further and create a demo RESTful API with the `HttpController` class, as shown below (Omit the source file):\n\n```c++\n\u002F\u002F\u002F The header file\n#pragma once\n#include \u003Cdrogon\u002FHttpController.h>\n\nusing namespace drogon;\n\nnamespace api::v1\n{\nclass User : public HttpController\u003CUser>\n{\n  public:\n    METHOD_LIST_BEGIN\n    \u002F\u002F use METHOD_ADD to add your custom processing function here;\n    METHOD_ADD(User::getInfo, \"\u002F{id}\", Get); \u002F\u002F path is \u002Fapi\u002Fv1\u002FUser\u002F{arg1}\n    METHOD_ADD(User::getDetailInfo, \"\u002F{id}\u002Fdetailinfo\", Get); \u002F\u002F path is \u002Fapi\u002Fv1\u002FUser\u002F{arg1}\u002Fdetailinfo\n    METHOD_ADD(User::newUser, \"\u002F{name}\", Post); \u002F\u002F path is \u002Fapi\u002Fv1\u002FUser\u002F{arg1}\n    METHOD_LIST_END\n    \u002F\u002F your declaration of processing function maybe like this:\n    void getInfo(const HttpRequestPtr &req, std::function\u003Cvoid(const HttpResponsePtr &)> &&callback, int userId) const;\n    void getDetailInfo(const HttpRequestPtr &req, std::function\u003Cvoid(const HttpResponsePtr &)> &&callback, int userId) const;\n    void newUser(const HttpRequestPtr &req, std::function\u003Cvoid(const HttpResponsePtr &)> &&callback, std::string &&userName);\n  public:\n    User()\n    {\n        LOG_DEBUG \u003C\u003C \"User constructor!\";\n    }\n};\n} \u002F\u002F namespace api::v1\n```\n\nAs you can see, users can use the `HttpController` to map paths and parameters at the same time. This is a very convenient way to create a RESTful API application.\n\nIn addition, you can also find that all handler interfaces are in asynchronous mode, where the response is returned by a callback object. This design is for performance reasons because in asynchronous mode the drogon application can handle a large number of concurrent requests with a small number of threads.\n\nAfter compiling all of the above source files, we get a very simple web application. This is a good start. **For more information, please visit the [documentation](https:\u002F\u002Fdrogonframework.github.io\u002Fdrogon-docs\u002F#\u002F) on GitHub**.\n\n## Cross-compilation\n\nDrogon supports cross-compilation, you should define the `CMAKE_SYSTEM_NAME` in toolchain file, for example:\n\n```cmake\nset(CMAKE_SYSTEM_NAME Linux)\nset(CMAKE_SYSTEM_PROCESSOR arm)\n```\n\nYou can disable building options for examples and drogon_ctl by settings `BUILD_EXAMPLES` and `BUILD_CTL` to `OFF` in the toolchain file.\n\n## Building options\n\nDrogon provides some building options, you can enable or disable them by setting the corresponding variables to `ON` or `OFF` in the cmake command line, cmake file etc...\n\n| Option name | Description | Default value |\n| :--- | :--- | :--- |\n| BUILD_CTL | Build drogon_ctl | ON |\n| BUILD_EXAMPLES | Build examples | ON |\n| BUILD_ORM | Build orm | ON |\n| COZ_PROFILING | Use coz for profiling | OFF |\n| BUILD_SHARED_LIBS | Build drogon as a shared lib | OFF |\n| BUILD_DOC | Build Doxygen documentation | OFF |\n| BUILD_BROTLI | Build Brotli | ON |\n| BUILD_YAML_CONFIG | Build yaml config | ON |\n| USE_SUBMODULE | Use trantor as a submodule | ON |\n\n\n## Contributions\n\nThis project exists thanks to all the people who contribute code.\n\n\u003Ca href=\"https:\u002F\u002Fgithub.com\u002Fdrogonframework\u002Fdrogon\u002Fgraphs\u002Fcontributors\">\u003Cimg src=\"https:\u002F\u002Fcontributors-svg.opencollective.com\u002Fdrogon\u002Fcontributors.svg?width=890&button=false\" alt=\"Code contributors\" \u002F>\u003C\u002Fa>\n\nEvery contribution is welcome. Please refer to the [contribution guidelines](CONTRIBUTING.md) for more information.\n","Drogon 是一个基于 C++17\u002F20 的高性能、跨平台 HTTP Web 应用框架。它采用非阻塞 I\u002FO（Linux 使用 epoll，macOS\u002FFreeBSD 使用 kqueue）和完全异步编程模型，支持 HTTP\u002F1.0\u002F1.1、HTTPS、WebSocket、RESTful API、服务端模板渲染（CSP）、会话管理、过滤器链及数据库异步访问等核心功能。适用于构建高并发 Web 服务、微服务后端、API 网关及需要低延迟与高吞吐的 C++ 后端系统，尤其适合对性能敏感且已有 C++ 技术栈的场景。",2,"trending"]