Fast🚀, efficient⌛️, and easiest💥 c++ async micro web framework based on ✨C++ Workflow✨.
C++ Workflow is a light-weighted C++ Parallel Computing and Asynchronous Networking Engine.
If you need performance and good productivity, you will love ✨wfrest✨.
- ✨wfrest: C++ Web Framework REST API
For more information, you can first see discussions:
https://github.com/wfrest/wfrest/discussions
sudo ./build.sh
For test
./test.sh
git clone https://github.com/wfrest/wfrest
cd wfrest
mkdir build && cd build
cmake ..
sudo make -j
sudo make install
Use dockerfile
docker build -t wfrest .
Or you can Pull from DockerHub
docker pull wfrest/wfrest
#include "wfrest/HttpServer.h"
using namespace wfrest;
int main()
{
HttpServer svr;
// curl -v http://ip:port/hello
svr.GET("/hello", [](const HttpReq *req, HttpResp *resp)
{
resp->String("world\n");
});
// curl -v http://ip:port/data
svr.GET("/data", [](const HttpReq *req, HttpResp *resp)
{
std::string str = "Hello world";
resp->String(std::move(str));
});
// curl -v http://ip:port/post -d 'post hello world'
svr.POST("/post", [](const HttpReq *req, HttpResp *resp)
{
// reference, no copy here
std::string& body = req->body();
fprintf(stderr, "post data : %s\n", body.c_str());
});
if (svr.start(8888) == 0)
{
getchar();
svr.stop();
} else
{
fprintf(stderr, "Cannot start server");
exit(1);
}
return 0;
}