Updated to new esp-idf
This commit is contained in:
@ -15,7 +15,6 @@ set(dependencies
|
||||
cpputils
|
||||
espchrono
|
||||
espcpputils
|
||||
expected
|
||||
fmt
|
||||
)
|
||||
|
||||
|
@ -54,15 +54,15 @@ void urldecode(char *dst, const char *src)
|
||||
*dst++ = '\0';
|
||||
}
|
||||
|
||||
tl::expected<void, std::string> urlverify(std::string_view str)
|
||||
std::expected<void, std::string> urlverify(std::string_view str)
|
||||
{
|
||||
if (str.empty())
|
||||
return tl::make_unexpected("empty url is not valid");
|
||||
return std::unexpected("empty url is not valid");
|
||||
|
||||
http_parser_url puri;
|
||||
http_parser_url_init(&puri);
|
||||
if (const auto result = http_parser_parse_url(str.data(), str.size(), 0, &puri); result != 0)
|
||||
return tl::make_unexpected(fmt::format("http_parser_parse_url() failed with {}", result));
|
||||
return std::unexpected(fmt::format("http_parser_parse_url() failed with {}", result));
|
||||
return {};
|
||||
}
|
||||
|
||||
@ -83,7 +83,7 @@ esp_err_t webserver_resp_send(httpd_req_t *req, ResponseStatus error, const char
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
tl::expected<std::string, std::string> webserver_get_query(httpd_req_t *req)
|
||||
std::expected<std::string, std::string> webserver_get_query(httpd_req_t *req)
|
||||
{
|
||||
std::string query;
|
||||
|
||||
@ -91,7 +91,7 @@ tl::expected<std::string, std::string> webserver_get_query(httpd_req_t *req)
|
||||
{
|
||||
query.resize(queryLength);
|
||||
if (const auto result = httpd_req_get_url_query_str(req, query.data(), query.size() + 1); result != ESP_OK)
|
||||
return tl::make_unexpected(fmt::format("httpd_req_get_url_query_str() failed with {}", esp_err_to_name(result)));
|
||||
return std::unexpected(fmt::format("httpd_req_get_url_query_str() failed with {}", esp_err_to_name(result)));
|
||||
}
|
||||
|
||||
return query;
|
||||
|
@ -3,13 +3,11 @@
|
||||
// system includes
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <expected>
|
||||
|
||||
// esp-idf includes
|
||||
#include <esp_http_server.h>
|
||||
|
||||
// 3rdparty lib includes
|
||||
#include <tl/expected.hpp>
|
||||
|
||||
// local includes
|
||||
#include "esphttpstatuscodes.h"
|
||||
|
||||
@ -20,13 +18,13 @@ template<typename T> T htmlentities(T &&val) { return val; } // TODO
|
||||
|
||||
void urldecode(char *dst, const char *src);
|
||||
|
||||
tl::expected<void, std::string> urlverify(std::string_view str);
|
||||
std::expected<void, std::string> urlverify(std::string_view str);
|
||||
|
||||
esp_err_t webserver_prepare_response(httpd_req_t *req);
|
||||
|
||||
esp_err_t webserver_resp_send(httpd_req_t *req, ResponseStatus error, const char *type, std::string_view body);
|
||||
|
||||
tl::expected<std::string, std::string> webserver_get_query(httpd_req_t *req);
|
||||
std::expected<std::string, std::string> webserver_get_query(httpd_req_t *req);
|
||||
|
||||
std::string toString(httpd_ws_type_t val);
|
||||
|
||||
|
Reference in New Issue
Block a user