|
@@ -33,8 +33,10 @@ http::Server &http::Server::start(int port) {
|
|
|
return *this;
|
|
|
}
|
|
|
|
|
|
-http::Server &http::Server::startSSL(int port) {
|
|
|
- ESP_LOGI(TAG, "startSSL(%d)", port);
|
|
|
+http::Server &http::Server::startSSL(const unsigned char *cert_start, const unsigned char *cert_end,
|
|
|
+ const unsigned char *key_start, const unsigned char *key_end,
|
|
|
+ int port) {
|
|
|
+ ESP_LOGI(TAG, "%s(%d)", __func__, port);
|
|
|
if (running) {
|
|
|
ESP_LOGE(TAG, "server already running");
|
|
|
ABORT("fix me");
|
|
@@ -42,16 +44,10 @@ http::Server &http::Server::startSSL(int port) {
|
|
|
|
|
|
handle = nullptr;
|
|
|
httpd_ssl_config_t conf = HTTPD_SSL_CONFIG_DEFAULT();
|
|
|
-
|
|
|
- extern const unsigned char cacert_pem_start[] asm("_binary_cert_pem_start");
|
|
|
- extern const unsigned char cacert_pem_end[] asm("_binary_cert_pem_end");
|
|
|
- conf.cacert_pem = cacert_pem_start;
|
|
|
- conf.cacert_len = cacert_pem_end - cacert_pem_start;
|
|
|
-
|
|
|
- extern const unsigned char prvtkey_pem_start[] asm("_binary_key_pem_start");
|
|
|
- extern const unsigned char prvtkey_pem_end[] asm("_binary_key_pem_end");
|
|
|
- conf.prvtkey_pem = prvtkey_pem_start;
|
|
|
- conf.prvtkey_len = prvtkey_pem_end - prvtkey_pem_start;
|
|
|
+ conf.cacert_pem = cert_start;
|
|
|
+ conf.cacert_len = cert_end - cert_start;
|
|
|
+ conf.prvtkey_pem = key_start;
|
|
|
+ conf.prvtkey_len = key_end - key_start;
|
|
|
|
|
|
CHECK(httpd_ssl_start(&handle, &conf));
|
|
|
|
|
@@ -62,7 +58,7 @@ http::Server &http::Server::startSSL(int port) {
|
|
|
}
|
|
|
|
|
|
void http::Server::registerUriHandlers() {
|
|
|
- ESP_LOGI(TAG, "registering URI handlers");
|
|
|
+ ESP_LOGD(TAG, "%s()", __func__);
|
|
|
for (auto &route : routes) {
|
|
|
ESP_LOGI(TAG, " method: %d; uri: %s", static_cast<int>(route.method), route.uri.c_str());
|
|
|
httpd_uri_t uriHandler = {
|
|
@@ -76,6 +72,7 @@ void http::Server::registerUriHandlers() {
|
|
|
}
|
|
|
|
|
|
void http::Server::stop() {
|
|
|
+ ESP_LOGI(TAG, "%s()", __func__);
|
|
|
CHECK(httpd_stop(handle));
|
|
|
running = false;
|
|
|
}
|
|
@@ -91,7 +88,7 @@ static string getDefaultStatusText(int status) {
|
|
|
|
|
|
esp_err_t http::Server::handleHttpRequest(httpd_req_t *httpdRequest) {
|
|
|
auto route = static_cast<Route *>(httpdRequest->user_ctx);
|
|
|
- ESP_LOGD(TAG, "handleHttpRequest; method: %d, path: \"%s\"", httpdRequest->method, route->uri.c_str());
|
|
|
+ ESP_LOGD(TAG, "%s; method: %d, path: \"%s\"", __func__, httpdRequest->method, route->uri.c_str());
|
|
|
|
|
|
auto request = Request(httpdRequest);
|
|
|
auto response = route->handler(request, route->data);
|