An Express-style HTTP framework in C++17 on libuv and llhttp, benchmarked against Express on one machine. In Microsoft’s vcpkg registry.
#include <PlusWeb/HttpServer.h>
int main() { HttpServer app(3000);
app.GET("/users/:id", [](HttpRequest& req, HttpResponse& res) {
res.status(200).send(nlohmann::json{
{"id", req.params["id"]},
{"name", "ada"},
});
});
app.serve([] { std::cout << "listening on :3000\n"; });
}It supports middleware chaining and since it uses tries for storing routes instead of a flat array like Express, the performance gets better as the application scales up
For example: At 5 Routes PlusWeb is 4.8x faster than express whereas at 10,000 routes it is 253x faster than express
Playground: https://amsozzer.com/projects/plusweb It is available to use on https://github.com/Amsozzer1/PlusWeb
Some more profiling info available on https://github.com/Amsozzer1/PlusWeb/blob/main/PROFILING_REP...
Learn more about my mistakes building PlusWeb and how I fixed them on https://amsozzer.com/writing/i-could-not-understand-express-...
0 comments
No comments yet.
Related stories
- The Verge · 0 points · 5 days ago
- The Verge · 0 points · 3 days ago
- Can John Ternus find Apple’s next big thing?theverge.comThe Verge · 0 points · 10 days ago
- Hacker News · 421 points · 6 days ago
- Lobsters · 86 points · about 1 year ago
- Hacker News · 1 points · 4 days ago