49 [[nodiscard]]
const uri& base_uri()
const {
50 return self().base_uri();
53 [[nodiscard]] abi::json commit_json_nop(
54 http_method method,
const uri& relative_uri,
const http_header_handler& header_handler = {})
const {
55 return self().commit_json_nop(method, relative_uri, header_handler);
58 [[nodiscard]] abi::json commit_json(http_method method,
const uri& relative_uri,
const abi::json& params,
59 const http_header_handler& header_handler = {})
const {
60 return self().commit_json(method, relative_uri, params, header_handler);
63 [[nodiscard]] abi::json commit_bytes(http_method method,
const uri& relative_uri, std::string_view content_type,
64 std::span<const std::byte> bytes,
const http_header_handler& header_handler = {})
const {
65 return self().commit_bytes(method, relative_uri, content_type, bytes, header_handler);
68 template <
byte_like_contiguous_range Range>
69 abi::json commit_bytes(http_method method,
const uri& relative_uri, std::string_view content_type,
70 Range&& bytes,
const http_header_handler& header_handler = {})
const {
71 return self().commit_bytes(method, relative_uri, content_type, as_const_byte_span(bytes), header_handler);
74 void on_progress(
const http_progress_handler& progress_handler)
const {
75 return self().on_progress(progress_handler);
80 auto commit_message(T&& message,
const http_header_handler& header_handler = {})
const {
81 using decayed_type = std::decay_t<T>;
84 static constexpr bool is_dummy_message = std::derived_from<decayed_type, dummy_body_tag>;
86 auto handler = [header_handler,
this]<
typename U>(U&& message) {
89 "An invalid \"message_transformer\" found.");
92 if constexpr (is_dummy_message) {
95 return abi::to_abi_json(rest_message_transformer_v<decayed_type>(std::forward<U>(message)));
97 return abi::to_abi_json(json(std::forward<U>(message)));
101 auto response = [&] {
102 auto raw_response = [&] {
103 if constexpr (is_dummy_message) {
104 return abi::from_abi_json(
105 commit_json_nop(traits_type::method, traits_type::relative_uri, header_handler));
107 return abi::from_abi_json(
108 commit_json(traits_type::method, traits_type::relative_uri, params, header_handler));
113 return raw_response.template get<typename traits_type::response_type>();
116 U8(
"Raw Response"), raw_response.dump(default_nested_exception_indent)});
122 "An invalid \"response_transformer\" found.");
125 return rest_response_transformer_v<decayed_type>(response);
131 auto message_content = [&] {
132 if constexpr (is_dummy_message) {
135 return json(message).dump(default_nested_exception_indent);
139 auto tuple = std::forward_as_tuple(std::forward<T>(message));
141 return throw_nested_and_flatten(
143 meta::get_literal_string_t<decayed_type,
147 U8(
"Raw Message"), message_content},
148 [&] {
return std::apply(handler, std::move(tuple)); });
154 Impl& self()
noexcept {
155 return static_cast<Impl&
>(*this);
158 const Impl& self()
const noexcept {
159 return static_cast<const Impl&
>(*this);