Represents an HTTP or Websocket response.
More...
#include <Response.hpp>
|
| Response (boost::beast::http::status status, std::string message, Request const &request) |
| Construct a Response from string. Content type will be text/html.
|
|
| Response (boost::beast::http::status status, boost::json::object const &message, Request const &request) |
| Construct a Response from JSON object. Content type will be application/json.
|
|
| Response (boost::beast::http::status status, boost::json::object const &message, Connection const &connection) |
| Construct a Response from string. Content type will be text/html.
|
|
| Response (boost::beast::http::status status, std::string message, Connection const &connection) |
| Construct a Response from string. Content type will be text/html.
|
|
| Response (boost::beast::http::response< boost::beast::http::string_body > response, Request const &request) |
| Construct a Response from HTTP response.
|
|
std::string const & | message () const |
| Get the message of the response.
|
|
void | setMessage (std::string newMessage) |
| Replace existing message (or body) with new message.
|
|
void | setMessage (boost::json::object const &newMessage) |
| Replace existing message (or body) with new message.
|
|
boost::beast::http::response< boost::beast::http::string_body > | intoHttpResponse () && |
| Convert the Response to an HTTP response.
|
|
boost::asio::const_buffer | asWsResponse () const & |
| Get the message of the response as a const buffer.
|
|
|
std::variant< boost::beast::http::response< boost::beast::http::string_body >, std::string > | data |
|
Represents an HTTP or Websocket response.
◆ Response() [1/5]
web::ng::Response::Response |
( |
boost::beast::http::status | status, |
|
|
std::string | message, |
|
|
Request const & | request ) |
Construct a Response from string. Content type will be text/html.
- Parameters
-
status | The HTTP status. It will be ignored if request is WebSocket. |
message | The message to send. |
request | The request that triggered this response. Used to determine whether the response should contain HTTP or WebSocket data. |
◆ Response() [2/5]
web::ng::Response::Response |
( |
boost::beast::http::status | status, |
|
|
boost::json::object const & | message, |
|
|
Request const & | request ) |
Construct a Response from JSON object. Content type will be application/json.
- Parameters
-
status | The HTTP status. It will be ignored if request is WebSocket. |
message | The message to send. |
request | The request that triggered this response. Used to determine whether the response should contain HTTP or WebSocket |
◆ Response() [3/5]
web::ng::Response::Response |
( |
boost::beast::http::status | status, |
|
|
boost::json::object const & | message, |
|
|
Connection const & | connection ) |
Construct a Response from string. Content type will be text/html.
- Parameters
-
status | The HTTP status. |
message | The message to send. |
connection | The connection that triggered this response. Used to determine whether the response should contain HTTP or WebSocket data. |
◆ Response() [4/5]
web::ng::Response::Response |
( |
boost::beast::http::status | status, |
|
|
std::string | message, |
|
|
Connection const & | connection ) |
Construct a Response from string. Content type will be text/html.
- Parameters
-
status | The HTTP status. |
message | The message to send. |
connection | The connection that triggered this response. Used to determine whether the response should contain HTTP or WebSocket data. |
◆ Response() [5/5]
web::ng::Response::Response |
( |
boost::beast::http::response< boost::beast::http::string_body > | response, |
|
|
Request const & | request ) |
Construct a Response from HTTP response.
- Parameters
-
response | The HTTP response. |
request | The request that triggered this response. It must be an HTTP request. |
◆ asWsResponse()
boost::asio::const_buffer web::ng::Response::asWsResponse |
( |
| ) |
const & |
Get the message of the response as a const buffer.
- Note
- The response must be constructed with a WebSocket request.
- Returns
- The message of the response as a const buffer.
◆ intoHttpResponse()
http::response< http::string_body > web::ng::Response::intoHttpResponse |
( |
| ) |
&& |
Convert the Response to an HTTP response.
- Note
- The Response must be constructed with an HTTP request.
- Returns
- The HTTP response.
◆ message()
std::string const & web::ng::Response::message |
( |
| ) |
const |
Get the message of the response.
- Returns
- The message of the response.
◆ setMessage() [1/2]
void web::ng::Response::setMessage |
( |
boost::json::object const & | newMessage | ) |
|
Replace existing message (or body) with new message.
- Parameters
-
newMessage | The new message. |
◆ setMessage() [2/2]
void web::ng::Response::setMessage |
( |
std::string | newMessage | ) |
|
Replace existing message (or body) with new message.
- Parameters
-
newMessage | The new message. |
The documentation for this class was generated from the following files:
- /__w/clio/clio/src/web/ng/Response.hpp
- /__w/clio/clio/src/web/ng/Response.cpp