Crow/include/http_request.h
ipknHama 9e851ec896 Handling macro issues
- fix IS_NUM conflict (for MySQL)
 - avoid DELETE, ERROR (for Windows)
2016-08-27 14:15:16 +09:00

53 lines
1.3 KiB
C++

#pragma once
#include "common.h"
#include "ci_map.h"
#include "query_string.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 raw_url;
std::string url;
query_string url_params;
ci_map headers;
std::string body;
void* middleware_context{};
request()
: method(HTTPMethod::Get)
{
}
request(HTTPMethod method, std::string raw_url, std::string url, query_string url_params, ci_map headers, std::string body)
: method(method), raw_url(std::move(raw_url)), url(std::move(url)), url_params(std::move(url_params)), headers(std::move(headers)), body(std::move(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) const
{
return crow::get_header_value(headers, key);
}
};
}