mirror of
https://github.com/esp8266/Arduino.git
synced 2025-06-28 05:01:28 +03:00
Add Uri with support for regexUri and globUri (#6696)
* Add path args * Add example * Update code format * Add missing include * Fix codestyle and unsigned int * fix unsigned int * Remove tabs * use vector<>.resize * rename j to requestUriIndex * using assert checking the path argument index * Add missing include "assert.h" * The order no longer matters. Path arguments may not contain the value '/' Updated the example * make pathArg return a const * Update PathArgServer.ino fix trailing space * const String& * Add regex support * Fix to match templating * Add Uri with support for staticUri, regexUri and globUri * Update example * Add deconstructor to remove _uri pointer * Add newline to end of files * Suppress gcc warnings (unused params) * Replace regex with regex.h * Use the standard STASSID/PSK settings for example Make the example match the existing examples which allow setting the SSID/PSK in the local platform.txt file. * Use 115.2Kbaud for example, match others Co-authored-by: david gauchard <gauchard@laas.fr> Co-authored-by: Earle F. Philhower, III <earlephilhower@yahoo.com>
This commit is contained in:
@ -29,6 +29,7 @@
|
||||
#include <ESP8266WiFi.h>
|
||||
#include <FS.h>
|
||||
#include "detail/mimetable.h"
|
||||
#include "Uri.h"
|
||||
|
||||
enum HTTPMethod { HTTP_ANY, HTTP_GET, HTTP_HEAD, HTTP_POST, HTTP_PUT, HTTP_PATCH, HTTP_DELETE, HTTP_OPTIONS };
|
||||
enum HTTPUploadStatus { UPLOAD_FILE_START, UPLOAD_FILE_WRITE, UPLOAD_FILE_END,
|
||||
@ -91,9 +92,9 @@ public:
|
||||
void requestAuthentication(HTTPAuthMethod mode = BASIC_AUTH, const char* realm = NULL, const String& authFailMsg = String("") );
|
||||
|
||||
typedef std::function<void(void)> THandlerFunction;
|
||||
void on(const String &uri, THandlerFunction handler);
|
||||
void on(const String &uri, HTTPMethod method, THandlerFunction fn);
|
||||
void on(const String &uri, HTTPMethod method, THandlerFunction fn, THandlerFunction ufn);
|
||||
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);
|
||||
void addHandler(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
|
||||
@ -107,6 +108,7 @@ public:
|
||||
// Allows setting server options (i.e. SSL keys) by the instantiator
|
||||
ServerType &getServer() { return _server; }
|
||||
|
||||
const String& pathArg(unsigned int i) const; // get request path argument by number
|
||||
const String& arg(const String& name) const; // get request argument value by name
|
||||
const String& arg(int i) const; // get request argument value by number
|
||||
const String& argName(int i) const; // get request argument name by number
|
||||
|
Reference in New Issue
Block a user