Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[自荐][开源] wfrest -- c++高性能异步restful网络框架 #2127

Open
chanchann opened this issue Dec 26, 2021 · 0 comments
Open

[自荐][开源] wfrest -- c++高性能异步restful网络框架 #2127

chanchann opened this issue Dec 26, 2021 · 0 comments

Comments

@chanchann
Copy link

项目地址

https://github.com/wfrest/wfrest

项目描述

  • 基于Sogou C++ Workflow开发的高性能异步restful网络框架
  • 低门槛,简洁的接口使c++用户能像go语言的gin,python的flask一样快速开发http restful的应用
  • 高性能,wfrest提供的http性能优于nginx
  • 与workflow互通,使得计算调度、异步文件IO等功能的使用更为方便,也可使用workflow的其他功能比如服务治理,mysql,redis等
  • 代码简洁易读,内部架构精巧,弥补了 workflow 在 web 功能上的不足,同时性能上有保证。
  • 独特的内存管理方式,不用借助智能指针,让内存管理更加方便

示例代码:

#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;
}
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

2 participants