#include <response.hpp>
HTTP response.
The body is written by a function when the response is sent, which allows streaming.
Setters return the response to chain them, on lvalues and on temporaries:
- Author
- Vincent Lachenal
- Since
- 0.2
◆ Response()
◆ body() [1/2]
| Response & anch::rest::Response::body |
( |
std::string | content | ) |
& |
Set body content
- Parameters
-
- Returns
this
◆ body() [2/2]
| Response && anch::rest::Response::body |
( |
std::string | content | ) |
&& |
Set body content
- Parameters
-
- Returns
this
◆ clearBody()
| void anch::rest::Response::clearBody |
( |
| ) |
|
|
noexcept |
Remove body (headers are kept)
◆ content()
| std::string anch::rest::Response::content |
( |
| ) |
const |
Get body content (body is written in a string)
- Returns
- the body content, empty when there is no body
◆ contentType() [1/2]
| Response & anch::rest::Response::contentType |
( |
std::string_view | mediaType | ) |
& |
Set Content-Type header
- Parameters
-
- Returns
this
◆ contentType() [2/2]
| Response && anch::rest::Response::contentType |
( |
std::string_view | mediaType | ) |
&& |
Set Content-Type header
- Parameters
-
- Returns
this
◆ getHeaders() [1/2]
◆ getHeaders() [2/2]
◆ getStatus()
Status getter
- Returns
- the status
◆ hasBody()
| bool anch::rest::Response::hasBody |
( |
| ) |
const |
|
noexcept |
Check if response has a body
- Returns
true when response has a body
◆ header() [1/2]
| Response & anch::rest::Response::header |
( |
std::string_view | name, |
|
|
std::string_view | value ) & |
Set header value
- Parameters
-
| name | the header name |
| value | the header value |
- Returns
this
◆ header() [2/2]
| Response && anch::rest::Response::header |
( |
std::string_view | name, |
|
|
std::string_view | value ) && |
Set header value
- Parameters
-
| name | the header name |
| value | the header value |
- Returns
this
◆ setStatus()
◆ stream() [1/2]
Set body writer
- Parameters
-
| writer | the function which writes the body |
- Returns
this
◆ stream() [2/2]
Set body writer
- Parameters
-
| writer | the function which writes the body |
- Returns
this
◆ writeBody()
| void anch::rest::Response::writeBody |
( |
std::ostream & | out | ) |
const |
Write body. Nothing is written when there is no body.
- Parameters
-
The documentation for this class was generated from the following file: