#include <request.hpp>
Public Member Functions | |
| Request () | |
| Request (anch::rest::Method method, std::string_view target) | |
| void | setTarget (std::string_view target) |
| std::optional< std::string_view > | getQueryParameter (std::string_view name) const |
| void | addQueryParameter (std::string_view name, std::string_view value) |
| std::optional< std::string_view > | getPathParameter (std::string_view name) const |
| std::optional< anch::codec::MediaType > | getContentType () const |
| std::vector< anch::codec::MediaType > | getAccept () const |
| bool | hasBody () const noexcept |
| std::istream & | getBody () const |
| void | setBody (std::unique_ptr< std::istream > body) |
| void | setBody (std::string body) |
| anch::rest::Method | getMethod () const noexcept |
| void | setMethod (anch::rest::Method method) noexcept |
| const std::string & | getPath () const noexcept |
| void | setPath (std::string_view path) |
| const std::vector< std::pair< std::string, std::string > > & | getQueryParameters () const noexcept |
| anch::rest::Headers & | getHeaders () noexcept |
| const anch::rest::Headers & | getHeaders () const noexcept |
| const std::map< std::string, std::string, std::less<> > & | getPathParameters () const noexcept |
| void | setPathParameters (std::map< std::string, std::string, std::less<> > parameters) |
HTTP request.
The path is kept percent-encoded (path parameters are decoded by the router); query parameters are decoded.
The request owns its body stream: it can be moved, not copied.
| anch::rest::Request::Request | ( | ) |
Request default constructor: GET /
| anch::rest::Request::Request | ( | anch::rest::Method | method, |
| std::string_view | target ) |
Request constructor
| method | the method |
| target | the request target (path and query, /pets?limit=10 ) |
| void anch::rest::Request::addQueryParameter | ( | std::string_view | name, |
| std::string_view | value ) |
Add a query parameter
| name | the parameter name |
| value | the parameter value |
| std::vector< anch::codec::MediaType > anch::rest::Request::getAccept | ( | ) | const |
Get Accept header media ranges (see anch::codec::MediaType::parseAccept )
| std::istream & anch::rest::Request::getBody | ( | ) | const |
| std::optional< anch::codec::MediaType > anch::rest::Request::getContentType | ( | ) | const |
Get Content-Type header
|
noexcept |
|
noexcept |
|
noexcept |
|
noexcept |
Path getter
| std::optional< std::string_view > anch::rest::Request::getPathParameter | ( | std::string_view | name | ) | const |
Get path parameter value
| name | the parameter name |
|
noexcept |
Path parameters getter
| std::optional< std::string_view > anch::rest::Request::getQueryParameter | ( | std::string_view | name | ) | const |
Get query parameter first value
| name | the parameter name |
|
noexcept |
Query parameters getter
|
noexcept |
Check if request has a body
true when request has a body | void anch::rest::Request::setBody | ( | std::string | body | ) |
Set body content
| body | the body content |
| void anch::rest::Request::setBody | ( | std::unique_ptr< std::istream > | body | ) |
Set body stream
| body | the body stream |
|
noexcept |
| void anch::rest::Request::setPath | ( | std::string_view | path | ) |
Path setter
| path | the percent-encoded path |
| void anch::rest::Request::setPathParameters | ( | std::map< std::string, std::string, std::less<> > | parameters | ) |
Path parameters setter
| parameters | the path parameters |
| void anch::rest::Request::setTarget | ( | std::string_view | target | ) |
Set path and query parameters from request target (/pets?limit=10 )
| target | the request target |