Added webserver_prepare_response()

This commit is contained in:
2021-08-09 19:09:58 +02:00
parent a78711317b
commit 4ebd651a70
2 changed files with 10 additions and 0 deletions

View File

@ -83,6 +83,14 @@ const char *errorToStatus(httpd_err_code_t error)
}
}
esp_err_t webserver_prepare_response(httpd_req_t *req)
{
CALL_AND_EXIT_ON_ERROR(httpd_resp_set_hdr, req, "Connection", "close")
CALL_AND_EXIT_ON_ERROR(httpd_resp_set_hdr, req, "Access-Control-Allow-Origin", "*")
return ESP_OK;
}
esp_err_t webserver_resp_send_succ(httpd_req_t *req, const char *type, std::string_view body)
{
CALL_AND_EXIT_ON_ERROR(httpd_resp_set_type, req, type)

View File

@ -21,6 +21,8 @@ tl::expected<void, std::string> urlverify(std::string_view str);
const char *errorToStatus(httpd_err_code_t error);
esp_err_t webserver_prepare_response(httpd_req_t *req);
esp_err_t webserver_resp_send_succ(httpd_req_t *req, const char *type, std::string_view body);
esp_err_t webserver_resp_send_err(httpd_req_t *req, httpd_err_code_t error, const char *type, std::string_view body);