# EVHttpServer
**Repository Path**: Q_uan/EVHttpServer
## Basic Information
- **Project Name**: EVHttpServer
- **Description**: No description available
- **Primary Language**: Unknown
- **License**: MIT
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2024-10-23
- **Last Updated**: 2025-09-03
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# Introduction
[](https://github.com/quanqixian/EVHttpServer/actions/workflows/build-test.yml)
[](https://github.com/quanqixian/EVHttpServer/blob/master/LICENSE)
[](https://quanqixian.github.io/EVHttpServer/)
EVHttpServer is just an http server implemented by encapsulating libevent using c++, It provides:
- Simpler api
- Use thread pool to handle http requests
- Support regular matching path
# Examples
See examples [here](./example).
Here is a simple example of using EVHttpServer:
```c++
#include "EVHttpServer.h"
#include
#include
#include
static volatile bool g_runFlag = true;
void sighandler(int signum)
{
g_runFlag = false;
}
void func(const EVHttpServer::HttpReq & req, EVHttpServer::HttpRes & res, void * arg)
{
std::cout << req.methodStr() << " " << req.path() << std::endl;
std::cout << req.body() << std::endl;
res.setBody(R"({"status":"OK"})");
res.setCode(200);
}
int main(int argc, const char *argv[])
{
EVHttpServer server;
server.addHandler({EVHttpServer::REQ_POST, "/api/fun"}, func);
server.init(9999);
server.start();
signal(SIGINT, sighandler);
while(g_runFlag)
{
std::this_thread::sleep_for(std::chrono::seconds(2));
}
return 0;
}
```
# API documentation
Click [here](https://quanqixian.github.io/EVHttpServer/) to jump to the api documentation generated by doxygen.
# Use in your project
The first way is to include the source code in the [src](./src) directory into your project, and then give libevent's header file path, library path and rpath when compiling.
The second way is to use EVHttpServer compiled as a library.
# Build
1. Clone the repository
```shell
git clone https://github.com/quanqixian/EVHttpServer.git
```
2. Generate the necessary build files
In this step, the third-party library will be cloned.
```cmake
cd EVHttpServer
cmake -B build -S . -DCMAKE_INSTALL_PREFIX=/path/to/install -DCMAKE_BUILD_TYPE=Release
```
3. Compile the source code. In this step, third-party libraries, EVHttpServer library, samples, tests will be compiled.
```cmake
cmake --build build
```
4. Install to system
```cmake
cmake --install build
```
Now you can use the EVHttpServer library, include the header file "EVHttpServer.h" in the code, link the libevent library and the EVHttpServer library when compiling.