diff options
author | ipkn <ipknhama@gmail.com> | 2014-04-17 10:06:41 -0400 |
---|---|---|
committer | ipkn <ipknhama@gmail.com> | 2014-04-17 10:06:41 -0400 |
commit | 86433135f3428cfd3f0184f10411bc169e2ae9b9 (patch) | |
tree | 0ebdbf7559ef73c1e69c3f6b0c6627cff422cfcc /http_response.h | |
parent | d908a2657e67f436f8158436d69c496aab94bdaa (diff) | |
download | crow-86433135f3428cfd3f0184f10411bc169e2ae9b9.tar.gz crow-86433135f3428cfd3f0184f10411bc169e2ae9b9.zip |
response can return json object
Diffstat (limited to 'http_response.h')
-rw-r--r-- | http_response.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/http_response.h b/http_response.h index f0acd9e..b12c8a5 100644 --- a/http_response.h +++ b/http_response.h @@ -1,17 +1,33 @@ #pragma once #include <string> #include <unordered_map> +#include "json.h" namespace flask { struct response { std::string body; + json::wvalue json_value; int code{200}; std::unordered_map<std::string, std::string> headers; 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(const json::wvalue& json_value) : body(json::encode(json_value)) {} response(int code, std::string body) : body(std::move(body)), code(code) {} + response(response&& r) + { + *this = std::move(r); + } + response& operator = (response&& r) + { + body = std::move(r.body); + json_value = std::move(r.json_value); + code = r.code; + headers = std::move(r.headers); + return *this; + } }; } |