#include "rotord.h" RotorRequestHandler::RotorRequestHandler(const std::string& format): _format(format){ } void RotorRequestHandler::handleRequest(HTTPServerRequest& request,HTTPServerResponse& response) { Timestamp now; std::string dt(DateTimeFormatter::format(now, _format)); response.setChunkedTransferEncoding(true); response.setContentType("text/html"); std::ostream& ostr = response.send(); ostr << "
"; ostr << dt; ostr << "
"; } RotorRequestHandlerFactory::RotorRequestHandlerFactory(const std::string& format):_format(format){ } HTTPRequestHandler* RotorRequestHandlerFactory::createRequestHandler(const HTTPServerRequest& request){ Application& app = Application::instance(); app.logger().information("Request from "+ request.clientAddress().toString()+": "+request.getURI()); if (request.getURI() == "/") return new RotorRequestHandler(_format); else return 0; } RotorServer::RotorServer(): _helpRequested(false) { } RotorServer::~RotorServer() { } void RotorServer::initialize(Application& self){ loadConfiguration(); ServerApplication::initialize(self); } void RotorServer::uninitialize(){ ServerApplication::uninitialize(); } void RotorServer::defineOptions(OptionSet& options) { ServerApplication::defineOptions(options); options.addOption( Option("help", "h", "display argument help information") .required(false) .repeatable(false) .callback(OptionCallback