Add basic auth for server static (#143)

* Add basic auth for server static

* Also effect to Websocket

* Add http basic auth for event source & document to README.md
This commit is contained in:
Tuan PM
2017-03-05 20:02:33 +02:00
committed by Me No Dev
parent bab5457584
commit 9b66da2c92
5 changed files with 25 additions and 1 deletions
+4 -1
View File
@@ -290,9 +290,12 @@ class AsyncWebRewrite {
class AsyncWebHandler {
protected:
ArRequestFilterFunction _filter;
String _username;
String _password;
public:
AsyncWebHandler(){}
AsyncWebHandler():_username(""), _password(""){}
AsyncWebHandler& setFilter(ArRequestFilterFunction fn) { _filter = fn; return *this; }
AsyncWebHandler& setAuthentication(const char *username, const char *password){ _username = String(username);_password = String(password);};
bool filter(AsyncWebServerRequest *request){ return _filter == NULL || _filter(request); }
virtual ~AsyncWebHandler(){}
virtual bool canHandle(AsyncWebServerRequest *request __attribute__((unused))){