Open-source C++ Web framework
Paozhu is a full-stack C++ framework that ships HTTP/2, ORM, annotations, RBAC and ACME in one binary. The guide below takes you from your first Hello World to production deployment.
0. Hello World — 5 lines of code
A controller is just a function with an //@urlpath annotation above it. The annotation generates the route registration, the permission mask, the rate-limit guard and the title string at build time. No registry to update, no stringly-typed map.
#include "testhello.h"
//@urlpath(null, hello)
asio::awaitable<std::string> testhello(std::shared_ptr<httppeer> peer)
{
peer->output = "Hello, world!";
co_return "";
}cmake .. -DCMAKE_BUILD_TYPE=Release && make -j8
./bin/paozhu --conf conf/server.conf
# Another shell
curl http://127.0.0.1/hello
# → Hello, world!The annotation //@urlpath(null, hello) means "public access, path is /hello". The CMake build scans the source tree, collects every //@urlpath, and emits common/autocontrolmethod.hpp — a table that maps each URL to its handler, its pre-filters, its permission bits and its rate-limit. The server reads that table at startup and never re-parses source or annotations.
1. What Paozhu is
Paozhu is a full-stack C++ web framework. Its documented core is a dual-pool model — an I/O coroutine pool plus a user-code worker pool — with Go-style HTTP scheduling. Routes are generated from //@urlpath annotations instead of a handwritten registry. HTTP/1.1, HTTP/2, WebSocket, JSON and ORM are implemented in the repository.
In the source: C++20, both CMake and xmake builds, default output at bin/paozhu; HTTP/2 enabled in conf/server.conf; MySQL, PostgreSQL and SQLite sections in conf/orm.conf; and a build-generated route table at common/autocontrolmethod.hpp.
2. What problems it solves
Building a production C++ web service usually means gluing five or six libraries together — boost::asio for I/O, a hand-written router, a DB connector, an ORM, an HTTP/2 library and a cert renewal tool — then wiring their configs, threads and error codes. Paozhu is opinionated about all of that. These four points tell you whether it fits your project.
Forget hand-written route registration
With pure asio you end up with a giant register_routes() function that repeats strings, bitsets and filters. Paozhu replaces that with one //@urlpath line above the controller. Add mask=SUPERADMIN, rate=60/10 or title="User list" on the same line and they are wired for you.
Don't write SQL by hand
Most C++ projects either concatenate SQL strings (risking injection and boilerplate) or pull in an ORM that feels alien to C++. Paozhu's three-layer ORM generates a field layer (compile-time metadata), an SQL layer (query builder) and a business shell (where you put your own logic). Regenerate the first two when your schema changes — your business code stays.
Protocol, security and ops in-process
Shipping nginx + ACME sh + your C++ binary means five moving pieces. Paozhu handles HTTP/2, WebSocket, session cookies, CSRF tokens, RBAC grant lookup, ZeroSSL ACME issuance and OCSP stapling inside the same process. One PID, one log, one config directory.
Run multiple sites with INI
Putting several domains behind one server usually means a reverse-proxy config, a process per domain or a lot of if (host == ...) in code. Paozhu's server.conf has one [default] section for global values and one [yourdomain.com] section per virtual site — each can override document root, HTTP/2, ACME and rate limits.
3. Architecture at a glance
TCP :80 / :443
|
+-- I/O coroutine pool -> HTTP/1.1 / HTTP/2 / WS parse
| |
| +-- route lookup (generated autocontrolmethod.hpp)
| |
| +-- maskcode? --> route_auth_hook (RBAC)
| |
| +-- pre filter -> controller
|
+-- worker threads -> C++ business code + ORM
|
+-- MySQL / PostgreSQL / SQLite poolsThe I/O coroutine pool parses the request and resolves the route. Routes with a maskcode pass through the auth hook before the pre-filter and controller. Business code runs on worker threads, and ORM models pick their connection pool by tag.