January 2019
Intermediate to advanced
458 pages
10h 35m
English
This handler implements a simple REST API, returning a JSON structure containing the current club status. This can be used by an external application to show real-time information on the system, which is useful for a dashboard or website.
Due to its simplicity, this class is also fully implemented in its header:
#include <Poco/Net/HTTPRequestHandler.h> #include <Poco/Net/HTTPServerResponse.h> #include <Poco/Net/HTTPServerRequest.h> #include <Poco/URI.h> using namespace Poco; using namespace Poco::Net; #include "club.h" class StatusHandler: public HTTPRequestHandler { public: void handleRequest(HTTPServerRequest& request, HTTPServerResponse& response) { Club::log(LOG_INFO, "StatusHandler: Request from " + request.clientAddress().toString()); ...