ehttp 基于 epoll 的轻量级 http server开源项目

我要开发同款
匿名用户2015年01月19日
30阅读
开发技术C/C++
所属分类服务器软件、HTTP服务器
授权协议Apache

作品详情

ehttp组件是为了使用c++方便快速的构建httpserver,编写基于http协议json格式的接口,和nginx等传统服务器相比,更加重视开发的便捷性,项目参考restbed实现。

特点

linux2.6+

多线程+epoll

强调简洁实用

依赖

simple_log日志组件

jsoncppjson序列化组件

性能

qps12000+(短连接ab-c10-n10000localhost:3490/hello)

qps16000+(长连接ab-c10-n10000-klocalhost:3490/hello)

构建&&测试 make && make test && ./output/bin/http_server_test 3490 curl "localhost:3490/hello"功能列表

http1.0/1.1(keep-alive支持)GET/POST请求

便捷的开发形式

Json格式的数据返回

例子#include#include#include"simple_log.h"#include"http_server.h"voidlogin(Request&request,Json::Value&root){std::stringname=request.get_param("name");std::stringpwd=request.get_param("pwd");LOG_DEBUG("loginuserwhichname:%s,pwd:%s",name.c_str(),pwd.c_str());root["code"]=0;root["msg"]="loginsuccess!";}intmain(){HttpServerhttp_server;http_server.add_mapping("/login",login,POST_METHOD);http_server.set_port(3456); http_server.start_sync();return0;}运行liao@ubuntu:~/workspace/simple_server$ curl "localhost:3490/login" -d "name=tom&pwd=3"{"code":0,"msg":"login success!"}
声明:本文仅代表作者观点,不代表本站立场。如果侵犯到您的合法权益,请联系我们删除侵权资源!如果遇到资源链接失效,请您通过评论或工单的方式通知管理员。未经允许,不得转载,本站所有资源文章禁止商业使用运营!
下载安装【程序员客栈】APP
实时对接需求、及时收发消息、丰富的开放项目需求、随时随地查看项目状态

评论