gitmyhub

drogon

C++ ★ 14k updated 15d ago

Drogon: A C++14/17/20 based HTTP web application framework running on Linux/macOS/Unix/Windows

Drogon is a high-performance C++17/20 web framework for building HTTP APIs and web applications, with async I/O, WebSocket support, built-in database access to PostgreSQL, MySQL, SQLite, and Redis, and a templating system, targeting low-latency server workloads.

C++C++17PostgreSQLMySQLSQLiteRedissetup: hardcomplexity 4/5

Drogon is a web server framework written in C++17/20. It lets you build HTTP-based applications and REST APIs in C++, running on Linux, macOS, Windows, and several BSD variants. The name comes from a dragon in the TV series Game of Thrones.

The framework is built around non-blocking I/O and asynchronous processing, meaning it handles many requests at once without dedicating a separate thread to each connection. This design targets high throughput and low latency, and the project references TechEmpower benchmark results to illustrate its performance compared to other frameworks.

On the feature side, Drogon supports HTTPS, WebSocket connections, JSON request and response handling, file upload and download, gzip and brotli compression, and built-in session management with cookies. It has a routing system that maps URL paths to controller classes, and a filter chain mechanism that lets you run shared checks (such as login verification) before requests reach their handlers. There is also a server-side templating system that embeds C++ code into HTML pages, with the framework compiling those templates automatically.

Database access is built in. Drogon can connect to PostgreSQL and MySQL asynchronously, SQLite3 via a thread pool, and Redis for caching. It includes a lightweight ORM so you can work with database rows as C++ objects. A command-line tool called drogon_ctl generates controller and view skeleton files so you spend less time writing boilerplate.

The typical Drogon application main function is just a few lines: configure the port and thread count, optionally load a JSON config file, and call run(). Controller logic lives in separate classes, and routing is declared via macros or the config file rather than crowding the startup code.

Where it fits