1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-06-28 05:01:28 +03:00

Implemented support for filters and removable routes in ESP8266WebServer (#9152)

* feat: added filters and removeable routes

* Update Filters.ino

* fix: clang-format

* chore: updated docs

* chore: updated doc

* fix: use new implementation

* fix: filters.ino example

* fix: filters.ino

* fix: formatting

* fix: formatting (2)
This commit is contained in:
Ayush Sharma
2024-06-15 23:50:13 +05:30
committed by GitHub
parent 685f2c97ff
commit 9afeaf5694
7 changed files with 317 additions and 30 deletions

View File

@ -116,11 +116,17 @@ public:
typedef std::function<void(void)> THandlerFunction;
typedef std::function<String(FS &fs, const String &fName)> ETagFunction;
typedef std::function<bool(ESP8266WebServerTemplate<ServerType> &server)> FilterFunction;
void on(const Uri &uri, THandlerFunction handler);
void on(const Uri &uri, HTTPMethod method, THandlerFunction fn);
void on(const Uri &uri, HTTPMethod method, THandlerFunction fn, THandlerFunction ufn);
RequestHandler<ServerType>& on(const Uri &uri, THandlerFunction handler);
RequestHandler<ServerType>& on(const Uri &uri, HTTPMethod method, THandlerFunction fn);
RequestHandler<ServerType>& on(const Uri &uri, HTTPMethod method, THandlerFunction fn, THandlerFunction ufn);
bool removeRoute(const char *uri);
bool removeRoute(const char *uri, HTTPMethod method);
bool removeRoute(const String &uri);
bool removeRoute(const String &uri, HTTPMethod method);
void addHandler(RequestHandlerType* handler);
bool removeHandler(RequestHandlerType* handler);
void serveStatic(const char* uri, fs::FS& fs, const char* path, const char* cache_header = NULL );
void onNotFound(THandlerFunction fn); //called when handler is not assigned
void onFileUpload(THandlerFunction fn); //handle file uploads
@ -306,6 +312,7 @@ public:
protected:
void _addRequestHandler(RequestHandlerType* handler);
bool _removeRequestHandler(RequestHandlerType *handler);
void _handleRequest();
void _finalizeResponse();
ClientFuture _parseRequest(ClientType& client);