Drogon Discord Gitter GitHub Issues Docs

Drogon, the fast C++ web framework

Run your application anywhere, knowing it is as fast as it could be.

View releases On GitHub

Features

Fast and asynchronous

Drogon is fully asynchronous and designed to have the lowest overhead without sacrificing usablity.

Portable

Drogon supports a wide range of platforms. Linux, Windows, OS X and *BSD. It also runs on different CPUs. x86, ARM, s390x, ...

Single core, > 150K requests/s

Drogon is multi threaded. But on a single core of a Ryzen 3700X. Drogon can process more than 150K HTTP requests per second.

C++ coroutines

Coroutine support allows users to write asynchronous code without bothering with the callback hell.

RDBMS & Redis

Drogon supports ORM and can connect to major open source DBs. It also speaks Redis for the in-memory goodness.

More...

Drogon is more than a HTTP server. It can also act as client, speak and serve Websocket and comes with helpful utilites.

Code snippets

Hello World

using Callback = std::function<void (const HttpResponsePtr &)> ;

app().registerHandler("/", [](const HttpRequestPtr& req, Callback &&callback)
{
	auto resp = HttpResponse::newHttpResponse();
	resp->setBody("Hello World");
	callback(resp);
});

File upload

app().registerHandler("/upload", [](const HttpRequestPtr& req, Callback &&callback))
{
	MultiPartParser fileUpload;
	if (fileUpload.parse(req) != 0 || fileUpload.getFiles().size() == 0) {
		// The framework handles an exception by logging it, and
		// by responding to the client with an HTTP 500 status code.
		throw std::runtime_error("Something went wrong");
	}

	auto &file = fileUpload.getFiles()[0];
	file.save();
	callback(HttpResponse::newHttpResponse());
});

DB with coroutines

app().registerHandler("/get_num_users", [](HttpRequestPtr req) -> Task<HttpResponsePtr>
{
	auto client = app().getDbClient();
	auto result = co_await client->execSqlCoro("SELECT COUNT(*) FROM users;");

	auto resp = HttpResponse::newHttpResponse();
	resp->setBody(std::to_string(result[0][0].as<size_t>()));
	co_return resp;
});

Sponsors

We are grateful for the organizations that have generously supported us:

Join Us

Getting started

Start using Drogon with these examples and the installation instructions.

Contribution

We welcome anyone to contribute to the project. In fact Drogon's development is driven by the community. Feel free to open an issue, or directly make a Pull Request. The maintainers will respond as soon as they see it and have time.

We also want to thank everyone whom contributed to the project: