mirror of
https://github.com/esphome/esphome.git
synced 2024-11-27 09:18:00 +01:00
online_image: nicer code style for http_request_headers
This commit is contained in:
parent
01c1894849
commit
dad61299b8
3 changed files with 8 additions and 7 deletions
|
@ -160,7 +160,9 @@ async def to_code(config):
|
|||
|
||||
for key in config.get(CONF_HTTP_REQUEST_HEADERS, []):
|
||||
template_ = await cg.templatable(
|
||||
config[CONF_HTTP_REQUEST_HEADERS][key], [], cg.optional.template(cg.const_char_ptr)
|
||||
config[CONF_HTTP_REQUEST_HEADERS][key],
|
||||
[],
|
||||
cg.optional.template(cg.const_char_ptr),
|
||||
)
|
||||
cg.add(var.add_header(key, template_))
|
||||
|
||||
|
|
|
@ -103,12 +103,11 @@ void OnlineImage::update() {
|
|||
ESP_LOGI(TAG, "Updating image");
|
||||
}
|
||||
|
||||
|
||||
std::list<http_request::Header> headers;
|
||||
for (const auto &item : this->headers_) {
|
||||
auto val = item.second();
|
||||
for (const auto &[key, value_template] : this->headers_) {
|
||||
auto val = value_template();
|
||||
if (val.has_value()) {
|
||||
headers.push_back(http_request::Header{item.first, *val});
|
||||
headers.push_back(http_request::Header{key, *val});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue