Malloy
Toggle main menu visibility
Loading...
Searching...
No Matches
lib
malloy
server
routing
type_traits.hpp
1
#pragma once
2
3
#include <concepts>
4
#include <variant>
5
6
#include "../../core/type_traits.hpp"
7
8
namespace
malloy::server::concepts
9
{
10
namespace
detail
11
{
12
template
<
typename
T>
13
concept
route_handler_retr
=
14
malloy::concepts::is_container_of<T, malloy::http::response, std::variant>
||
15
malloy::concepts::is<T, malloy::http::response>
;
16
17
template
<
typename
Func,
typename
... Args>
18
concept
route_handler_helper
=
19
std::invocable<Func, Args...> &&
20
requires
(Func f, Args... args) {
21
{ std::invoke(f, args...) } ->
route_handler_retr
;
22
};
23
}
24
25
template
<
typename
F,
typename
Req>
26
concept
route_handler
=
27
detail::route_handler_helper<F, const Req&>
||
28
detail::route_handler_helper<F, const Req&, const std::vector<std::string>
>;
29
30
template
<
typename
Func>
31
concept
websocket_handler
= std::invocable <Func, const malloy::http::request_header<>&,
const
std::shared_ptr<websocket::connection>&>;
32
33
template
<
typename
H>
34
concept
request_filter
=
35
std::move_constructible<H> &&
36
requires
(
const
H& f,
const
typename
H::request_type::header_type& h,
typename
H::request_type::body_type::value_type& v)
37
{
38
{ f.setup_body(h, v) };
39
};
40
41
template
<
typename
P>
42
concept
request_validator
=
requires
(P p,
const
boost::beast::http::request_header<>& h) {
43
{ std::invoke(p, h) } ->
malloy::concepts::is_container_of<malloy::http::response, std::optional>
;
44
};
45
46
}
// namespace malloy::server::concepts
47
malloy::concepts::is_container_of
Definition
type_traits.hpp:120
malloy::concepts::is
Definition
type_traits.hpp:101
malloy::server::concepts::detail::route_handler_helper
Definition
type_traits.hpp:18
malloy::server::concepts::detail::route_handler_retr
Definition
type_traits.hpp:13
malloy::server::concepts::request_filter
Definition
type_traits.hpp:34
malloy::server::concepts::request_validator
Definition
type_traits.hpp:42
malloy::server::concepts::route_handler
Definition
type_traits.hpp:26
malloy::server::concepts::websocket_handler
Definition
type_traits.hpp:31
Generated by
1.18.0