4#ifndef _Stroika_Framework_WebService_Server_ObjectRequestHandler_h_
5#define _Stroika_Framework_WebService_Server_ObjectRequestHandler_h_ 1
7#include "Stroika/Frameworks/StroikaPreComp.h"
11#include "Stroika/Foundation/Common/Concepts.h"
12#include "Stroika/Foundation/Containers/Sequence.h"
14#include "Stroika/Foundation/DataExchange/ObjectVariantMapper.h"
17#include "Stroika/Frameworks/WebServer/RequestHandler.h"
19#include "Stroika/Frameworks/WebService/Server/Basic.h"
20#include "Stroika/Frameworks/WebService/Server/VariantValue.h"
26namespace Stroika::Frameworks::WebService::Server::ObjectRequestHandler {
33 using Common::Select_t;
42 using WebServer::Request;
43 using WebServer::Response;
66 static_assert (not copyable<Context>);
67 static_assert (not movable<Context>);
105 optional<DataExchange::Variant::JSON::Writer::Options> fJSONWriterOptions;
109 nonvirtual
String ToString ()
const;
111 static_assert (copyable<Options>);
152 template <
typename RETURN_TYPE,
typename... ARG_TYPES>
155 static_assert (not is_reference_v<RETURN_TYPE>);
162 template <qCompilerAndStdLib_ConstraintDiffersInTemplateRedeclaration_BWA (invocable<ARG_TYPES...>) CALLBACK_FUNCTION>
163 Factory (
const Options& options, CALLBACK_FUNCTION&& highLevelHandler);
211 nonvirtual RETURN_TYPE ApplyObjectHandler (ARG_TYPES... args)
const;
216 template <
typename T>
217 nonvirtual T ConvertArg2Object (
const VariantValue& v)
const;
222 template <
typename RET = RETURN_TYPE>
224 [[maybe_unused]]
const function<RET ()>& f)
const;
225 template <
typename SINGLE_ARG>
227 [[maybe_unused]]
const function<RETURN_TYPE (SINGLE_ARG)>& f)
const;
228 template <
typename ARG_FIRST,
typename... REST_ARG_TYPES>
230 [[maybe_unused]]
const function<RETURN_TYPE (ARG_FIRST, REST_ARG_TYPES...)>& f)
const
231 ->
decltype (tuple_cat (make_tuple (declval<remove_cvref_t<ARG_FIRST>> ()), make_tuple (declval<REST_ARG_TYPES...> ())));
239 template <same_as<RETURN_TYPE> RT>
242 requires (same_as<RETURN_TYPE, void>);
249 template <same_as<RETURN_TYPE> RT>
253 function<RETURN_TYPE (ARG_TYPES...)> fHighLevelHandler_;
259 template <
typename CALLBACK_FUNCTION,
size_t i>
260 using CBArg_t_ = remove_cvref_t<typename FunctionTraits<CALLBACK_FUNCTION>::template ArgOrVoid_t<i>>;
265 template <
typename CALLBACK_FUNCTION>
266 Factory (
const Options&, CALLBACK_FUNCTION&&) -> Factory<invoke_result_t<CALLBACK_FUNCTION>>;
267 template <
typename CALLBACK_FUNCTION>
268 Factory (
const Options&, CALLBACK_FUNCTION&&)
269 -> Factory<invoke_result_t<CALLBACK_FUNCTION, Private_::CBArg_t_<CALLBACK_FUNCTION, 0>>, Private_::CBArg_t_<CALLBACK_FUNCTION, 0>>;
270 template <
typename CALLBACK_FUNCTION>
271 Factory (
const Options&, CALLBACK_FUNCTION&&)
272 -> Factory<invoke_result_t<CALLBACK_FUNCTION, Private_::CBArg_t_<CALLBACK_FUNCTION, 0>, Private_::CBArg_t_<CALLBACK_FUNCTION, 1>>,
273 Private_::CBArg_t_<CALLBACK_FUNCTION, 0>, Private_::CBArg_t_<CALLBACK_FUNCTION, 1>>;
274 template <
typename CALLBACK_FUNCTION>
275 Factory (
const Options&, CALLBACK_FUNCTION&&)
276 -> Factory<invoke_result_t<CALLBACK_FUNCTION, Private_::CBArg_t_<CALLBACK_FUNCTION, 0>, Private_::CBArg_t_<CALLBACK_FUNCTION, 1>, Private_::CBArg_t_<CALLBACK_FUNCTION, 2>>,
277 Private_::CBArg_t_<CALLBACK_FUNCTION, 0>, Private_::CBArg_t_<CALLBACK_FUNCTION, 1>, Private_::CBArg_t_<CALLBACK_FUNCTION, 2>>;
278 template <
typename CALLBACK_FUNCTION>
279 Factory (
const Options&, CALLBACK_FUNCTION&&)
280 -> Factory<invoke_result_t<CALLBACK_FUNCTION, Private_::CBArg_t_<CALLBACK_FUNCTION, 0>, Private_::CBArg_t_<CALLBACK_FUNCTION, 1>,
281 Private_::CBArg_t_<CALLBACK_FUNCTION, 2>, Private_::CBArg_t_<CALLBACK_FUNCTION, 3>>,
282 Private_::CBArg_t_<CALLBACK_FUNCTION, 0>, Private_::CBArg_t_<CALLBACK_FUNCTION, 1>,
283 Private_::CBArg_t_<CALLBACK_FUNCTION, 2>, Private_::CBArg_t_<CALLBACK_FUNCTION, 3>>;
292#include "ObjectRequestHandler.inl"
String is like std::u32string, except it is much easier to use, often much more space efficient,...
A generalization of a vector: a container whose elements are keyed by the natural numbers.
ObjectVariantMapper can be used to map C++ types to and from variant-union types, which can be transp...
Simple variant-value (case variant union) object, with (variant) basic types analogous to a value in ...
Iterable<T> is a base class for containers which easily produce an Iterator<T> to traverse them.
this represents a HTTP request object for the WebServer module
ObjectRequestHandler::Factory is a way to construct a WebServer::RequestHandler from an ObjectVariant...
nonvirtual void SendStringResponse(const Request &request, Response &response, const RT &r) const
nonvirtual void SendResponse(const Request &request, Response &response, const RT &r) const
nonvirtual RETURN_TYPE ApplyHandler(const Context &context) const
Extract the number of arguments, return type, and each individual argument type from a lambda or simp...
ConnectionManager::Options specify things like default headers, caching policies, binding flags (not ...
not directly instantiated, but to receive context arguments in callbacks.
const Sequence< String > & fMatchedURLArgs
nonvirtual String ToString() const
Options for ObjectRequestHandler - mostly the ObjectVariantMapper, but also a few others depending on...
optional< Iterable< String > > fTreatBodyAsListOfArguments
optional< Set< String > > fAllowedMethods
optional< InternetMediaType > fDefaultResultMediaType