Skip to content

Vestiacom/libeverest

Repository files navigation

Everest

LibEverest is a library for embedding a HTTP server inside a C++ application. It uses libev and http-parser.

Build

mkdir build && cd build
cmake ..
make
sudo make install

Test

./everest-tests --catch_system_errors=no

Example usage

#include <ev++.h>
#include <everest/everest.hpp>

int setup() {
	// Server configuration
	everest::Config serverConfig("localhost:5000");
	serverConfig.cleanupPeriodSec = 5; // seconds
	serverConfig.maxConnections = 1000; // max concurrent connections

	struct ev_loop* loop = EV_DEFAULT;

	everest::Server server(serverConfig, loop);
	server.endpoint("/v1/status", [&](const std::shared_ptr<everest::Request>& r) {
		auto response = r->createResponse();
		response->setHeader("A", "B");
		response->setStatus(200);
		response->appendBody("{\"status\":\"OK\"}");
		response->send();
	});

	server.endpoint("/v1/stop", [&](const std::shared_ptr<everest::Request>& r) {
		server.stop();
		ev_break(loop, EVBREAK_ALL);
	});

	// Starts accepting connections
	server.start();

	// Runs till ev_break is called
	ev_run(loop, 0);
}

About

Modern C++ library for embedding a HTTP server with libev

Resources

License

Stars

Watchers

Forks

Packages

No packages published