#include <client.hpp>
Public Member Functions | |
| Call (anch::rest::Client &client, anch::rest::Request request) | |
| Call & | header (std::string_view name, std::string_view value) & |
| Call && | header (std::string_view name, std::string_view value) && |
| template<anch::rest::ParameterValue T> | |
| Call & | query (std::string_view name, const T &value) & |
| template<anch::rest::ParameterValue T> | |
| Call && | query (std::string_view name, const T &value) && |
| template<typename C> | |
| Call< Codecs..., C > | accept () && |
| template<typename C, typename T> | |
| Call & | body (const T &value) & |
| template<typename C, typename T> | |
| Call && | body (const T &value) && |
| Call & | body (std::string content, std::string_view contentType) & |
| Call && | body (std::string content, std::string_view contentType) && |
| Call & | body (std::unique_ptr< std::istream > input, std::string_view contentType, std::optional< std::uint64_t > size=std::nullopt) & |
| Call && | body (std::unique_ptr< std::istream > input, std::string_view contentType, std::optional< std::uint64_t > size=std::nullopt) && |
| Call & | body (anch::rest::RawBody raw) & |
| Call && | body (anch::rest::RawBody raw) && |
| anch::rest::Response | send () && |
| void | execute () && |
| template<typename T> | |
| T | as () && |
| anch::rest::Request & | getRequest () noexcept |
Friends | |
| template<typename...> | |
| class | Call |
Request being built by Client .
Accepted codecs are part of the type: accept adds a codec and as deserializes the response with the accepted codec matching its Content-Type :
A call is sent once: send , execute and as are called on rvalues.
| Codecs | the accepted codecs |
| anch::rest::Call< Codecs >::Call | ( | anch::rest::Client & | client, |
| anch::rest::Request | request ) |
Call constructor
| client | the client |
| request | the request |
| Call< Codecs..., C > anch::rest::Call< Codecs >::accept | ( | ) | && |
Accept codec media type (added to Accept header)
| C | the codec |
Send request and deserialize response with the accepted codec matching its Content-Type
| T | the result type (default constructible) |
| anch::rest::HttpError | when status is an error (>= 400) |
| anch::rest::TransportError | when request fails |
| std::runtime_error | when response content type is not accepted |
| std::exception | codec errors |
| Call & anch::rest::Call< Codecs >::body | ( | anch::rest::RawBody | raw | ) | & |
Set raw body (see above)
| raw | the raw body |
this | Call && anch::rest::Call< Codecs >::body | ( | anch::rest::RawBody | raw | ) | && |
Set raw body (see above)
| raw | the raw body |
this | Call & anch::rest::Call< Codecs >::body | ( | const T & | value | ) | & |
Set body serialized with codec (Content-Type is the codec media type)
| C | the codec |
| value | the body value |
this | Call && anch::rest::Call< Codecs >::body | ( | const T & | value | ) | && |
Set body serialized with codec (Content-Type is the codec media type)
| C | the codec |
| value | the body value |
this | Call & anch::rest::Call< Codecs >::body | ( | std::string | content, |
| std::string_view | contentType ) & |
Set body content
| content | the body content |
| contentType | the content type |
this | Call && anch::rest::Call< Codecs >::body | ( | std::string | content, |
| std::string_view | contentType ) && |
Set body content
| content | the body content |
| contentType | the content type |
this | Call & anch::rest::Call< Codecs >::body | ( | std::unique_ptr< std::istream > | input, |
| std::string_view | contentType, | ||
| std::optional< std::uint64_t > | size = std::nullopt ) & |
Set body stream: it is read by the transport when the request is sent (with a size, the libcurl transport streams it: large bodies are not loaded in memory)
| input | the body stream |
| contentType | the content type |
| size | the body size ( Content-Length ), empty when unknown |
this | Call && anch::rest::Call< Codecs >::body | ( | std::unique_ptr< std::istream > | input, |
| std::string_view | contentType, | ||
| std::optional< std::uint64_t > | size = std::nullopt ) && |
Set body stream (see above)
| input | the body stream |
| contentType | the content type |
| size | the body size ( Content-Length ), empty when unknown |
this | void anch::rest::Call< Codecs >::execute | ( | ) | && |
Send request and check response status
| anch::rest::HttpError | when status is an error (>= 400) |
| anch::rest::TransportError | when request fails |
|
noexcept |
Request getter
| Call & anch::rest::Call< Codecs >::header | ( | std::string_view | name, |
| std::string_view | value ) & |
Set request header
| name | the header name |
| value | the header value |
this | Call && anch::rest::Call< Codecs >::header | ( | std::string_view | name, |
| std::string_view | value ) && |
Set request header
| name | the header name |
| value | the header value |
this | Call & anch::rest::Call< Codecs >::query | ( | std::string_view | name, |
| const T & | value ) & |
Add query parameter (it is encoded)
| name | the parameter name |
| value | the parameter value |
this | Call && anch::rest::Call< Codecs >::query | ( | std::string_view | name, |
| const T & | value ) && |
Add query parameter (it is encoded)
| name | the parameter name |
| value | the parameter value |
this | anch::rest::Response anch::rest::Call< Codecs >::send | ( | ) | && |
Send request
| anch::rest::TransportError | when request fails |
|
friend |
Calls with other codecs are friends (accept )