This project is a cpp http server lib, wrapped of libevent.
It provides some basic http server features like handler regist, url/header/body parse, set response code/header/body and so on.
More information on Straka's blog
- Based on libevent.
- No c interface exposed.
- User friendly interface.
#include "EvHttpServ.h"
#include "Utilis/Defer.h"
#include "Utilis/Logger.h"
using namespace Network;
int main()
{
Utilis::Logger::GetInstance()->StartLogging();
Utilis::DEFER([] { Utilis::Logger::GetInstance()->StopLogging(); });
EvHttpServ Serv("0.0.0.0\0", 8077);
Serv.RegistHandler("/hi/testget", [](EvHttpResp *resp){resp->QuickResponse(200,"Hello World!\n");});
Serv.Start();
return 0;
}
More examples can be found in folder "example".
Post
, Put
, Delete
and Options
methods are NOT supported yet.
It is recommended to use g++ 4.9+ to support c++11 features better.
-
Download:
git clone --recursive https://github.com/atp798/EvHttp.git
-
Build:
mkdir build && cd build && cmake ../ && make
-
Run sample:
./EvHttpExample1
-
Test the http server:
curl -X GET x.x.x.x:8077/hi/testget
. The ip address 'x.x.x.x' should be replaced by the server ip address.
- Make it thread-safe.
- Add http client feature.
- Add tcp server & client.
- Support https.
- Support udp.
- Multi-platform support (Windows first).
- Start logging thread when needed.
MIT license (© 2019 ATP)