summaryrefslogtreecommitdiffstats
path: root/server/src/http_common.cppm
blob: f56c92bf017e4f0b887400e1b3ee538b7f4812eb (about) (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
module;

#include <boost/beast/core.hpp>
#include <boost/beast/http.hpp>

export module routemon:http.common;

namespace beast = boost::beast;
export namespace bhttp = beast::http;

namespace boost::beast {

namespace concepts {

template <class T>
concept buffers_generator = beast::is_buffers_generator<T>::value;

template <class T>
concept const_buffer_sequence = beast::is_const_buffer_sequence<T>::value;

} // namespace concepts

namespace http::concepts {

template <class T>
concept fields = is_fields<T>::value;

template <class T>
concept body = is_body<T>::value;

template <class T>
concept body_reader = is_body_reader<T>::value;

} // namespace http::concepts

} // namespace boost::beast

namespace routemon::http {

struct supported_verb
{
  enum supported_verb_t : std::uint8_t
  {
    options,
    delete_,
    get,
    head,
    post,
    put,
  };

  supported_verb_t value;

  supported_verb(supported_verb_t value);

  static auto from(bhttp::verb v) -> std::optional<supported_verb>;

  operator bhttp::verb() const;
};

export struct verb_set
{
  bool options : 1 = false;
  bool delete_ : 1 = false;
  bool get : 1 = false;
  bool head : 1 = false;
  bool post : 1 = false;
  bool put : 1 = false;

  [[nodiscard]] auto with(supported_verb v) const noexcept -> verb_set;
  [[nodiscard]] auto empty() const noexcept -> bool;
  [[nodiscard]] auto to_string() const -> std::string;

  auto operator==(verb_set const& rhs) const noexcept -> bool = default;
};
static_assert(sizeof(verb_set) == 1);
static_assert(alignof(verb_set) == 1);

} // namespace routemon::http