Malloy
Toggle main menu visibility
Loading...
Searching...
No Matches
lib
malloy
core
http
response.hpp
1
#pragma once
2
3
#include "types.hpp"
4
#include "cookie.hpp"
5
#include "../utils.hpp"
6
7
#include <boost/beast/core.hpp>
8
#include <boost/beast/http.hpp>
9
#include <boost/beast/version.hpp>
10
11
#include <filesystem>
12
13
namespace
malloy::http
14
{
15
19
template
<
typename
Body = boost::beast::http::
string
_body,
typename
Fields = boost::beast::http::fields>
20
class
response
:
21
public
boost::beast::http::response<Body, Fields>
22
{
23
using
msg_t = boost::beast::http::response<Body, Fields>;
24
25
public
:
29
response
() =
default
;
30
36
explicit
37
response
(msg_t&& msg)
38
{
39
msg_t::operator=(std::move(msg));
40
}
41
47
explicit
48
response
(
const
boost::beast::http::response_header<Fields>& header) :
49
msg_t{ header }
50
{
51
}
52
58
explicit
59
response
(boost::beast::http::response_header<Fields>&& header) :
60
msg_t{ std::move(header) }
61
{
62
}
63
69
explicit
70
response
(
const
status
& status_)
71
{
72
msg_t::result(status_);
73
}
74
80
response
(
const
response
& other) =
default
;
81
87
response
(
response
&& other)
noexcept
=
default
;
88
92
virtual
93
~response
() =
default
;
94
101
response
&
102
operator=
(
const
response
& rhs) =
default
;
103
110
response
&
111
operator=
(
response
&& rhs)
noexcept
=
default
;
112
118
void
119
set_status
(
http::status
status
) { msg_t::result(
status
); }
120
126
[[nodiscard]]
127
http::status
128
status
()
const
{
return
msg_t::result(); }
129
135
void
136
add_cookie
(
const
cookie
& c)
137
{
138
msg_t::insert(malloy::http::field::set_cookie, c.to_string());
139
}
140
};
141
142
}
143
144
#include <sstream>
145
146
namespace
malloy
147
{
148
149
template
<
typename
Body,
typename
Fields>
150
[[nodiscard]]
151
std::string
152
to_string
(
const
http::response<Body, Fields>& r)
153
{
154
std::ostringstream ss;
155
ss << r;
156
157
return
ss.str();
158
}
159
160
}
malloy::http::cookie
Definition
cookie.hpp:20
malloy::http::response::set_status
void set_status(http::status status)
Definition
response.hpp:119
malloy::http::response::operator=
response & operator=(const response &rhs)=default
malloy::http::response::response
response(boost::beast::http::response_header< Fields > &&header)
Definition
response.hpp:59
malloy::http::response::response
response(msg_t &&msg)
Definition
response.hpp:37
malloy::http::response::add_cookie
void add_cookie(const cookie &c)
Definition
response.hpp:136
malloy::http::response::response
response(const boost::beast::http::response_header< Fields > &header)
Definition
response.hpp:48
malloy::http::response::response
response()=default
malloy::http::response::response
response(const response &other)=default
malloy::http::response::operator=
response & operator=(response &&rhs) noexcept=default
malloy::http::response< boost::beast::http::file_body >::status
http::status status() const
Definition
response.hpp:128
malloy::http::response::~response
virtual ~response()=default
malloy::http::response::response
response(response &&other) noexcept=default
malloy::http::response::response
response(const status &status_)
Definition
response.hpp:70
malloy::http
Definition
cookie.hpp:8
malloy::http::status
boost::beast::http::status status
Definition
types.hpp:23
malloy
Definition
controller.hpp:32
malloy::to_string
std::string_view to_string(const malloy::http::method method)
Definition
http.hpp:26
Generated by
1.18.0