hoopd, Nginx inspired, and will be a simple and easy to use web framework written in modern C++.
g++ 8.4 +
cmake 3.17 +
- Build robust and scalable RESTful APIs
- Group APIs
- Data binding for JSON
- Handy functions to send variety of HTTP responses
- Centralized HTTP error handling
- WIP
mkdir build && cd build && cmake .. && make
- Server
#include <hoopd.h>
using namespace hoopd;
class Echo {
public:
std::string echo() {
std::string body{"Hi there; my name is hoopd, Good to see you."};
return body;
}
};
int main() {
Hoopd server;
server.set_scope("/api/v2");
server.get("/echo", [](const http::Request& req, http::Response& res) {
Echo e;
std::string message = e.echo();
std::string k{"Cache-control"};
std::string v{"no-cache"};
res.header.headers(k, v);
res.body = message;
req.description();
res.description();
});
server.run();
}
- client: Use curl
curl http://127.0.0.1:9527/api/v2/echo
- client: Or Use python
python client.py
- output
Hi there; my name is hoopd, Good to see you.
More examples can be found in the examples directory.
- zTgx - Author