mirror of
https://github.com/esphome/esphome.git
synced 2026-03-01 10:24:19 -07:00
Merge branch 'web_server_use_arg_api' into integration
This commit is contained in:
@@ -1175,12 +1175,13 @@ void WebServer::handle_date_request(AsyncWebServerRequest *request, const UrlMat
|
||||
|
||||
auto call = obj->make_call();
|
||||
|
||||
if (!request->hasArg(ESPHOME_F("value"))) {
|
||||
// .c_str() is required for Arduino framework where arg() returns Arduino String instead of std::string
|
||||
std::string value = request->arg(ESPHOME_F("value")).c_str(); // NOLINT(readability-redundant-string-cstr)
|
||||
if (value.empty()) {
|
||||
request->send(409);
|
||||
return;
|
||||
}
|
||||
|
||||
parse_string_param_(request, ESPHOME_F("value"), call, &decltype(call)::set_date);
|
||||
call.set_date(value);
|
||||
|
||||
DEFER_ACTION(call, call.perform());
|
||||
request->send(200);
|
||||
@@ -1235,12 +1236,13 @@ void WebServer::handle_time_request(AsyncWebServerRequest *request, const UrlMat
|
||||
|
||||
auto call = obj->make_call();
|
||||
|
||||
if (!request->hasArg(ESPHOME_F("value"))) {
|
||||
// .c_str() is required for Arduino framework where arg() returns Arduino String instead of std::string
|
||||
std::string value = request->arg(ESPHOME_F("value")).c_str(); // NOLINT(readability-redundant-string-cstr)
|
||||
if (value.empty()) {
|
||||
request->send(409);
|
||||
return;
|
||||
}
|
||||
|
||||
parse_string_param_(request, ESPHOME_F("value"), call, &decltype(call)::set_time);
|
||||
call.set_time(value);
|
||||
|
||||
DEFER_ACTION(call, call.perform());
|
||||
request->send(200);
|
||||
@@ -1294,12 +1296,13 @@ void WebServer::handle_datetime_request(AsyncWebServerRequest *request, const Ur
|
||||
|
||||
auto call = obj->make_call();
|
||||
|
||||
if (!request->hasArg(ESPHOME_F("value"))) {
|
||||
// .c_str() is required for Arduino framework where arg() returns Arduino String instead of std::string
|
||||
std::string value = request->arg(ESPHOME_F("value")).c_str(); // NOLINT(readability-redundant-string-cstr)
|
||||
if (value.empty()) {
|
||||
request->send(409);
|
||||
return;
|
||||
}
|
||||
|
||||
parse_string_param_(request, ESPHOME_F("value"), call, &decltype(call)::set_datetime);
|
||||
call.set_datetime(value);
|
||||
|
||||
DEFER_ACTION(call, call.perform());
|
||||
request->send(200);
|
||||
|
||||
@@ -544,9 +544,9 @@ class WebServer : public Controller,
|
||||
template<typename T, typename Ret>
|
||||
void parse_string_param_(AsyncWebServerRequest *request, ParamNameType param_name, T &call,
|
||||
Ret (T::*setter)(const std::string &)) {
|
||||
if (request->hasArg(param_name)) {
|
||||
// .c_str() is required for Arduino framework where arg() returns Arduino String instead of std::string
|
||||
std::string value = request->arg(param_name).c_str(); // NOLINT(readability-redundant-string-cstr)
|
||||
// .c_str() is required for Arduino framework where arg() returns Arduino String instead of std::string
|
||||
std::string value = request->arg(param_name).c_str(); // NOLINT(readability-redundant-string-cstr)
|
||||
if (!value.empty()) {
|
||||
(call.*setter)(value);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user