From 7bba7176194c4d1d9c7066f8eda7a94491d924e6 Mon Sep 17 00:00:00 2001 From: Rutger Broekhoff Date: Mon, 30 Nov 2026 21:27:55 +0100 Subject: Cleanups and updates --- server/src/http/core/common.cppm | 79 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 server/src/http/core/common.cppm (limited to 'server/src/http/core/common.cppm') diff --git a/server/src/http/core/common.cppm b/server/src/http/core/common.cppm new file mode 100644 index 0000000..e8fbe42 --- /dev/null +++ b/server/src/http/core/common.cppm @@ -0,0 +1,79 @@ +module; + +#include +#include + +export module routemon:http.core.common; + +namespace beast = boost::beast; +export namespace bhttp = beast::http; + +namespace boost::beast { + +namespace concepts { + +template +concept buffers_generator = beast::is_buffers_generator::value; + +template +concept const_buffer_sequence = beast::is_const_buffer_sequence::value; + +} // namespace concepts + +namespace http::concepts { + +template +concept fields = is_fields::value; + +template +concept body = is_body::value; + +template +concept body_reader = is_body_reader::value; + +} // namespace http::concepts + +} // namespace boost::beast + +namespace routemon::http::core { + +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; + + 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::core -- cgit v1.3.1