HTTP server class wrapping the esp-idf http server.
More...
#include <sensesp/net/http_server.h>
|
| HTTPServer (int port=HTTP_DEFAULT_PORT, const String &config_path="/system/httpserver") |
|
void | stop () |
|
void | set_auth_credentials (const String &username, const String &password, bool auth_required=true) |
|
void | set_captive_portal (bool captive_portal) |
|
virtual bool | to_json (JsonObject &config) override |
|
virtual bool | from_json (const JsonObject &config) override |
|
void | add_handler (std::shared_ptr< HTTPRequestHandler > &handler) |
|
| FileSystemSaveable (const String &config_path) |
|
virtual bool | load () override |
| Load and populate the object from a persistent storage.
|
|
virtual bool | save () override |
| Save the object to a persistent storage.
|
|
virtual bool | clear () override |
| Delete the data from a persistent storage.
|
|
bool | find_config_file (const String &config_path, String &filename) |
|
| Saveable (const String &config_path) |
|
virtual bool | refresh () |
| Refresh the object. This may or may not access the persistent storage but is not expected to overwrite the object's state.
|
|
const String & | get_config_path () const |
|
|
bool | authenticate_request (HTTPAuthenticator *auth, std::function< esp_err_t(httpd_req_t *)> handler, httpd_req_t *req) |
|
esp_err_t | dispatch_request (httpd_req_t *req) |
| Dispatcher method that captures all requests and forwards them to the appropriate handlers.
|
|
bool | handle_captive_portal (httpd_req_t *req) |
| Check if the request is for the captive portal and handle it if it.
|
|
HTTP server class wrapping the esp-idf http server.
Definition at line 61 of file http_server.h.
◆ HTTPServer()
sensesp::HTTPServer::HTTPServer |
( |
int | port = HTTP_DEFAULT_PORT, |
|
|
const String & | config_path = "/system/httpserver" ) |
|
inline |
◆ add_handler()
◆ authenticate_request()
bool sensesp::HTTPServer::authenticate_request |
( |
HTTPAuthenticator * | auth, |
|
|
std::function< esp_err_t(httpd_req_t *)> | handler, |
|
|
httpd_req_t * | req ) |
|
protected |
◆ dispatch_request()
esp_err_t sensesp::HTTPServer::dispatch_request |
( |
httpd_req_t * | req | ) |
|
|
protected |
Dispatcher method that captures all requests and forwards them to the appropriate handlers.
- Parameters
-
- Returns
- esp_err_t
Definition at line 40 of file http_server.cpp.
◆ from_json()
virtual bool sensesp::HTTPServer::from_json |
( |
const JsonObject & | root | ) |
|
|
inlineoverridevirtual |
◆ handle_captive_portal()
bool sensesp::HTTPServer::handle_captive_portal |
( |
httpd_req_t * | req | ) |
|
|
protected |
Check if the request is for the captive portal and handle it if it.
- Parameters
-
- Returns
- true Request was handled
-
false Request was not handled
Definition at line 122 of file http_server.cpp.
◆ set_auth_credentials()
void sensesp::HTTPServer::set_auth_credentials |
( |
const String & | username, |
|
|
const String & | password, |
|
|
bool | auth_required = true ) |
|
inline |
◆ set_captive_portal()
void sensesp::HTTPServer::set_captive_portal |
( |
bool | captive_portal | ) |
|
|
inline |
◆ stop()
void sensesp::HTTPServer::stop |
( |
| ) |
|
|
inline |
◆ to_json()
virtual bool sensesp::HTTPServer::to_json |
( |
JsonObject & | root | ) |
|
|
inlineoverridevirtual |
◆ call_request_dispatcher
esp_err_t call_request_dispatcher |
( |
httpd_req_t * | req | ) |
|
|
friend |
◆ auth_required_
bool sensesp::HTTPServer::auth_required_ = false |
|
protected |
◆ authenticator_
◆ captive_portal_
bool sensesp::HTTPServer::captive_portal_ = false |
|
protected |
◆ config_
httpd_config_t sensesp::HTTPServer::config_ |
|
protected |
◆ handlers_
◆ password_
String sensesp::HTTPServer::password_ |
|
protected |
◆ server_
httpd_handle_t sensesp::HTTPServer::server_ = nullptr |
|
protected |
◆ username_
String sensesp::HTTPServer::username_ |
|
protected |
The documentation for this class was generated from the following files: