Crow/http_response.h

34 lines
991 B
C
Raw Normal View History

2014-04-01 12:25:16 +00:00
#pragma once
#include <string>
#include <unordered_map>
2014-04-17 14:06:41 +00:00
#include "json.h"
2014-04-01 12:25:16 +00:00
2014-04-26 17:19:59 +00:00
namespace crow
2014-04-01 12:25:16 +00:00
{
struct response
{
std::string body;
2014-04-17 14:06:41 +00:00
json::wvalue json_value;
int code{200};
2014-04-01 12:25:16 +00:00
std::unordered_map<std::string, std::string> headers;
response() {}
explicit response(int code) : code(code) {}
response(std::string body) : body(std::move(body)) {}
2014-04-17 14:06:41 +00:00
response(json::wvalue&& json_value) : json_value(std::move(json_value)) {}
2014-04-18 22:12:56 +00:00
response(const json::wvalue& json_value) : body(json::dump(json_value)) {}
response(int code, std::string body) : body(std::move(body)), code(code) {}
2014-04-17 14:06:41 +00:00
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;
}
2014-04-01 12:25:16 +00:00
};
}