aboutsummaryrefslogtreecommitdiffstats
path: root/http_response.h
diff options
context:
space:
mode:
authoripkn <ipknhama@gmail.com>2014-04-17 10:06:41 -0400
committeripkn <ipknhama@gmail.com>2014-04-17 10:06:41 -0400
commit86433135f3428cfd3f0184f10411bc169e2ae9b9 (patch)
tree0ebdbf7559ef73c1e69c3f6b0c6627cff422cfcc /http_response.h
parentd908a2657e67f436f8158436d69c496aab94bdaa (diff)
downloadcrow-86433135f3428cfd3f0184f10411bc169e2ae9b9.tar.gz
crow-86433135f3428cfd3f0184f10411bc169e2ae9b9.zip
response can return json object
Diffstat (limited to 'http_response.h')
-rw-r--r--http_response.h16
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;
+ }
};
}