Permalink
Fetching contributors…
Cannot retrieve contributors at this time
34 lines (23 sloc) 699 Bytes
/*
Mathieu Stefani, 13 février 2016
Example of an hello world server
*/
#include "pistache/endpoint.h"
using namespace Pistache;
class HelloHandler : public Http::Handler {
public:
HTTP_PROTOTYPE(HelloHandler)
void onRequest(const Http::Request& request, Http::ResponseWriter response) {
response.send(Http::Code::Ok, "Hello World");
}
};
int main() {
Pistache::Address addr(Pistache::Ipv4::any(), Pistache::Port(9080));
auto opts = Pistache::Http::Endpoint::options()
.threads(1);
Http::Endpoint server(addr);
server.init(opts);
server.setHandler(Http::make_handler<HelloHandler>());
server.serve();
server.shutdown();
}