diff options
author | ipkn <ipknhama@gmail.com> | 2015-04-14 16:25:09 +0900 |
---|---|---|
committer | ipkn <ipknhama@gmail.com> | 2015-04-14 16:25:09 +0900 |
commit | c94fc46a7a7b8a2947e3625edbfd5ee2c4ce9817 (patch) | |
tree | 36c35e36b77f37ed482421c85367684efad43aae /include/http_response.h | |
parent | db932564646921a29ffde96c85bab67381017f4a (diff) | |
parent | 441a9f6e615ee37ed863b2b3bcb50f8380cc39cb (diff) | |
download | crow-c94fc46a7a7b8a2947e3625edbfd5ee2c4ce9817.tar.gz crow-c94fc46a7a7b8a2947e3625edbfd5ee2c4ce9817.zip |
Merge pull request #58 from gabrielbiga/crow_gabriel
Fix Content-Type not setted passing JSON object by rvalue reference.
Diffstat (limited to 'include/http_response.h')
-rw-r--r-- | include/http_response.h | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/include/http_response.h b/include/http_response.h index 6e22418..c84856b 100644 --- a/include/http_response.h +++ b/include/http_response.h @@ -40,11 +40,14 @@ namespace crow response() {} explicit response(int code) : code(code) {} response(std::string body) : body(std::move(body)) {} - response(json::wvalue&& json_value) : json_value(std::move(json_value)) {} + response(json::wvalue&& json_value) : json_value(std::move(json_value)) + { + json_mode(); + } response(int code, std::string body) : body(std::move(body)), code(code) {} response(const json::wvalue& json_value) : body(json::dump(json_value)) { - set_header("Content-Type", "application/json"); + json_mode(); } response(response&& r) @@ -111,5 +114,11 @@ namespace crow bool completed_{}; std::function<void()> complete_request_handler_; std::function<bool()> is_alive_helper_; + + //In case of a JSON object, set the Content-Type header + void json_mode() + { + set_header("Content-Type", "application/json"); + } }; } |