diff options
Diffstat (limited to 'include/http_request.h')
-rw-r--r-- | include/http_request.h | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/include/http_request.h b/include/http_request.h index af623c6..7d2da67 100644 --- a/include/http_request.h +++ b/include/http_request.h @@ -1,16 +1,38 @@ #pragma once #include "common.h" +#include "ci_map.h" namespace crow { + template <typename T> + inline const std::string& get_header_value(const T& headers, const std::string& key) + { + if (headers.count(key)) + { + return headers.find(key)->second; + } + static std::string empty; + return empty; + } + struct request { HTTPMethod method; std::string url; - std::unordered_map<std::string, std::string> headers; + ci_map headers; std::string body; + void add_header(std::string key, std::string value) + { + headers.emplace(std::move(key), std::move(value)); + } + + const std::string& get_header_value(const std::string& key) + { + return crow::get_header_value(headers, key); + } + void* middleware_context{}; }; } |