#ifndef REQUESTHANDLER_H #define REQUESTHANDLER_H #include #include #include template class RequestHandler { using WebServerType = ESP8266WebServerTemplate; public: virtual ~RequestHandler() { } virtual bool canHandle(HTTPMethod method, const String& uri) { (void) method; (void) uri; return false; } virtual bool canUpload(const String& uri) { (void) uri; return false; } virtual bool handle(WebServerType& server, HTTPMethod requestMethod, const String& requestUri) { (void) server; (void) requestMethod; (void) requestUri; return false; } virtual void upload(WebServerType& server, const String& requestUri, HTTPUpload& upload) { (void) server; (void) requestUri; (void) upload; } RequestHandler* next() { return _next; } void next(RequestHandler* r) { _next = r; } private: RequestHandler* _next = nullptr; protected: std::vector pathArgs; public: const String& pathArg(unsigned int i) { assert(i < pathArgs.size()); return pathArgs[i]; } }; #endif //REQUESTHANDLER_H