diff options
| author | Rutger Broekhoff | 2026-11-30 23:33:26 +0100 |
|---|---|---|
| committer | Rutger Broekhoff | 2026-11-30 23:33:26 +0100 |
| commit | 4a81c39d94b6877f7753896218467ff77b8d7f6f (patch) | |
| tree | f046f52f4f81e9951b7531d795c169a16e7e6e54 /server/src/http | |
| parent | 7bba7176194c4d1d9c7066f8eda7a94491d924e6 (diff) | |
| download | routemon-4a81c39d94b6877f7753896218467ff77b8d7f6f.tar.gz routemon-4a81c39d94b6877f7753896218467ff77b8d7f6f.zip | |
class -> typename
Diffstat (limited to 'server/src/http')
| -rw-r--r-- | server/src/http/core/client.cppm | 2 | ||||
| -rw-r--r-- | server/src/http/core/common.cppm | 10 | ||||
| -rw-r--r-- | server/src/http/core/server.cppm | 42 | ||||
| -rw-r--r-- | server/src/http/ext/hmac_openssl.cppm | 1 | ||||
| -rw-r--r-- | server/src/http/handler.cpp | 2 |
5 files changed, 28 insertions, 29 deletions
diff --git a/server/src/http/core/client.cppm b/server/src/http/core/client.cppm index ada4f03..2bf1137 100644 --- a/server/src/http/core/client.cppm +++ b/server/src/http/core/client.cppm | |||
| @@ -25,7 +25,7 @@ export class client | |||
| 25 | public: | 25 | public: |
| 26 | explicit client(net::io_context& ioc); | 26 | explicit client(net::io_context& ioc); |
| 27 | 27 | ||
| 28 | template <class ReqBody> | 28 | template <typename ReqBody> |
| 29 | auto do_request(bhttp::request<ReqBody>& req) | 29 | auto do_request(bhttp::request<ReqBody>& req) |
| 30 | -> bhttp::response<bhttp::dynamic_body> | 30 | -> bhttp::response<bhttp::dynamic_body> |
| 31 | { | 31 | { |
diff --git a/server/src/http/core/common.cppm b/server/src/http/core/common.cppm index e8fbe42..83d474f 100644 --- a/server/src/http/core/common.cppm +++ b/server/src/http/core/common.cppm | |||
| @@ -12,23 +12,23 @@ namespace boost::beast { | |||
| 12 | 12 | ||
| 13 | namespace concepts { | 13 | namespace concepts { |
| 14 | 14 | ||
| 15 | template <class T> | 15 | template <typename T> |
| 16 | concept buffers_generator = beast::is_buffers_generator<T>::value; | 16 | concept buffers_generator = beast::is_buffers_generator<T>::value; |
| 17 | 17 | ||
| 18 | template <class T> | 18 | template <typename T> |
| 19 | concept const_buffer_sequence = beast::is_const_buffer_sequence<T>::value; | 19 | concept const_buffer_sequence = beast::is_const_buffer_sequence<T>::value; |
| 20 | 20 | ||
| 21 | } // namespace concepts | 21 | } // namespace concepts |
| 22 | 22 | ||
| 23 | namespace http::concepts { | 23 | namespace http::concepts { |
| 24 | 24 | ||
| 25 | template <class T> | 25 | template <typename T> |
| 26 | concept fields = is_fields<T>::value; | 26 | concept fields = is_fields<T>::value; |
| 27 | 27 | ||
| 28 | template <class T> | 28 | template <typename T> |
| 29 | concept body = is_body<T>::value; | 29 | concept body = is_body<T>::value; |
| 30 | 30 | ||
| 31 | template <class T> | 31 | template <typename T> |
| 32 | concept body_reader = is_body_reader<T>::value; | 32 | concept body_reader = is_body_reader<T>::value; |
| 33 | 33 | ||
| 34 | } // namespace http::concepts | 34 | } // namespace http::concepts |
diff --git a/server/src/http/core/server.cppm b/server/src/http/core/server.cppm index dbef975..19eb1c4 100644 --- a/server/src/http/core/server.cppm +++ b/server/src/http/core/server.cppm | |||
| @@ -146,17 +146,17 @@ public: | |||
| 146 | }; | 146 | }; |
| 147 | static_assert(beast::concepts::buffers_generator<presponse>); | 147 | static_assert(beast::concepts::buffers_generator<presponse>); |
| 148 | 148 | ||
| 149 | template <class Ctx> | 149 | template <typename Ctx> |
| 150 | using next_handler_t = std::function<auto(Ctx)->net::awaitable<presponse>>; | 150 | using next_handler_t = std::function<auto(Ctx)->net::awaitable<presponse>>; |
| 151 | 151 | ||
| 152 | template <class OuterCtx, class InnerCtx> | 152 | template <typename OuterCtx, typename InnerCtx> |
| 153 | using middleware_t = | 153 | using middleware_t = |
| 154 | std::function<auto( | 154 | std::function<auto( |
| 155 | OuterCtx, bhttp::request_header<bhttp::fields>&, | 155 | OuterCtx, bhttp::request_header<bhttp::fields>&, |
| 156 | next_handler_t<InnerCtx>) | 156 | next_handler_t<InnerCtx>) |
| 157 | ->net::awaitable<presponse>>; | 157 | ->net::awaitable<presponse>>; |
| 158 | 158 | ||
| 159 | template <class Ctx> | 159 | template <typename Ctx> |
| 160 | auto id_middleware( | 160 | auto id_middleware( |
| 161 | Ctx ctx, bhttp::request_header<bhttp::fields>&, next_handler_t<Ctx> next) | 161 | Ctx ctx, bhttp::request_header<bhttp::fields>&, next_handler_t<Ctx> next) |
| 162 | -> net::awaitable<presponse> | 162 | -> net::awaitable<presponse> |
| @@ -170,14 +170,14 @@ struct base_ctx | |||
| 170 | trace::id trace_id; | 170 | trace::id trace_id; |
| 171 | }; | 171 | }; |
| 172 | 172 | ||
| 173 | template <class Ctx> | 173 | template <typename Ctx> |
| 174 | using basic_route_handler_fn_t = | 174 | using basic_route_handler_fn_t = |
| 175 | std::function<auto( | 175 | std::function<auto( |
| 176 | Ctx, readable_request, | 176 | Ctx, readable_request, |
| 177 | std::vector<std::string> const& matches) | 177 | std::vector<std::string> const& matches) |
| 178 | ->net::awaitable<presponse>>; | 178 | ->net::awaitable<presponse>>; |
| 179 | 179 | ||
| 180 | template <class Ctx> | 180 | template <typename Ctx> |
| 181 | auto cors_middleware(std::vector<std::string> const& allow_origins) | 181 | auto cors_middleware(std::vector<std::string> const& allow_origins) |
| 182 | -> middleware_t<Ctx, Ctx> | 182 | -> middleware_t<Ctx, Ctx> |
| 183 | { | 183 | { |
| @@ -199,7 +199,7 @@ auto cors_middleware(std::vector<std::string> const& allow_origins) | |||
| 199 | }; | 199 | }; |
| 200 | } | 200 | } |
| 201 | 201 | ||
| 202 | template <class Ctx> | 202 | template <typename Ctx> |
| 203 | auto expose_trace_id_middleware( | 203 | auto expose_trace_id_middleware( |
| 204 | Ctx ctx, bhttp::request_header<bhttp::fields>& req_hdr, | 204 | Ctx ctx, bhttp::request_header<bhttp::fields>& req_hdr, |
| 205 | next_handler_t<Ctx> next) -> net::awaitable<presponse> | 205 | next_handler_t<Ctx> next) -> net::awaitable<presponse> |
| @@ -214,7 +214,7 @@ auto expose_trace_id_middleware( | |||
| 214 | co_return std::move(prersp); | 214 | co_return std::move(prersp); |
| 215 | } | 215 | } |
| 216 | 216 | ||
| 217 | template <class Ctx> | 217 | template <typename Ctx> |
| 218 | auto expose_content_language_middleware( | 218 | auto expose_content_language_middleware( |
| 219 | Ctx ctx, bhttp::request_header<bhttp::fields>& req_hdr, | 219 | Ctx ctx, bhttp::request_header<bhttp::fields>& req_hdr, |
| 220 | next_handler_t<Ctx> next) -> net::awaitable<presponse> | 220 | next_handler_t<Ctx> next) -> net::awaitable<presponse> |
| @@ -297,17 +297,17 @@ auto read_empty_request(base_ctx const& ctx, readable_request&& r) -> net:: | |||
| 297 | co_return r.p->release(); | 297 | co_return r.p->release(); |
| 298 | } | 298 | } |
| 299 | 299 | ||
| 300 | template <class InnerCtx> | 300 | template <typename InnerCtx> |
| 301 | struct routed_ctx : InnerCtx | 301 | struct routed_ctx : InnerCtx |
| 302 | { | 302 | { |
| 303 | verb_set route_methods; | 303 | verb_set route_methods; |
| 304 | boost::urls::url target; | 304 | boost::urls::url target; |
| 305 | }; | 305 | }; |
| 306 | 306 | ||
| 307 | template <class Ctx> | 307 | template <typename Ctx> |
| 308 | requires requires(Ctx ctx) { | 308 | requires requires(Ctx ctx) { |
| 309 | // Ctx must be derived from an instantiation of routed_ctx | 309 | // Ctx must be derived from an instantiation of routed_ctx |
| 310 | []<class InnerCtx>(routed_ctx<InnerCtx> const&) {}(ctx); | 310 | []<typename InnerCtx>(routed_ctx<InnerCtx> const&) {}(ctx); |
| 311 | } | 311 | } |
| 312 | auto default_options_handler( | 312 | auto default_options_handler( |
| 313 | Ctx const& ctx, readable_request r, std::vector<std::string> const&) | 313 | Ctx const& ctx, readable_request r, std::vector<std::string> const&) |
| @@ -343,7 +343,7 @@ auto default_options_handler( | |||
| 343 | auto global_options_handler(base_ctx const& ctx, readable_request r) | 343 | auto global_options_handler(base_ctx const& ctx, readable_request r) |
| 344 | -> net::awaitable<presponse>; | 344 | -> net::awaitable<presponse>; |
| 345 | 345 | ||
| 346 | template <class A, class B, class C> | 346 | template <typename A, typename B, typename C> |
| 347 | auto middleware_compose(middleware_t<A, B> ab, middleware_t<B, C> bc) | 347 | auto middleware_compose(middleware_t<A, B> ab, middleware_t<B, C> bc) |
| 348 | -> middleware_t<A, C> | 348 | -> middleware_t<A, C> |
| 349 | { | 349 | { |
| @@ -357,7 +357,7 @@ auto middleware_compose(middleware_t<A, B> ab, middleware_t<B, C> bc) | |||
| 357 | }; | 357 | }; |
| 358 | } | 358 | } |
| 359 | 359 | ||
| 360 | template <class A, class B> | 360 | template <typename A, typename B> |
| 361 | auto middleware_wrap_fn(middleware_t<A, B> ab, basic_route_handler_fn_t<B> fn) | 361 | auto middleware_wrap_fn(middleware_t<A, B> ab, basic_route_handler_fn_t<B> fn) |
| 362 | -> basic_route_handler_fn_t<A> | 362 | -> basic_route_handler_fn_t<A> |
| 363 | { | 363 | { |
| @@ -386,7 +386,7 @@ struct handler_map | |||
| 386 | V post = {}; | 386 | V post = {}; |
| 387 | V put = {}; | 387 | V put = {}; |
| 388 | 388 | ||
| 389 | template <class Self> | 389 | template <typename Self> |
| 390 | auto lookup(this Self&& self, supported_verb v) -> auto&& | 390 | auto lookup(this Self&& self, supported_verb v) -> auto&& |
| 391 | { | 391 | { |
| 392 | switch (v.value) | 392 | switch (v.value) |
| @@ -436,7 +436,7 @@ struct handler_map | |||
| 436 | } | 436 | } |
| 437 | }; | 437 | }; |
| 438 | 438 | ||
| 439 | template <class Ctx> | 439 | template <typename Ctx> |
| 440 | struct route_tree | 440 | struct route_tree |
| 441 | { | 441 | { |
| 442 | using leaves = handler_map<basic_route_handler_fn_t<Ctx>>; | 442 | using leaves = handler_map<basic_route_handler_fn_t<Ctx>>; |
| @@ -451,7 +451,7 @@ struct route_tree | |||
| 451 | std::variant<named_subtrees, wildcard_subtree> sub; | 451 | std::variant<named_subtrees, wildcard_subtree> sub; |
| 452 | }; | 452 | }; |
| 453 | 453 | ||
| 454 | template <class OuterCtx, class InnerCtx> | 454 | template <typename OuterCtx, typename InnerCtx> |
| 455 | auto middleware_wrap_tree( | 455 | auto middleware_wrap_tree( |
| 456 | middleware_t<OuterCtx, InnerCtx> mw, route_tree<InnerCtx> const& tree) | 456 | middleware_t<OuterCtx, InnerCtx> mw, route_tree<InnerCtx> const& tree) |
| 457 | -> route_tree<OuterCtx> | 457 | -> route_tree<OuterCtx> |
| @@ -479,15 +479,15 @@ auto middleware_wrap_tree( | |||
| 479 | return {.here = new_leaves, .sub = new_sub}; | 479 | return {.here = new_leaves, .sub = new_sub}; |
| 480 | } | 480 | } |
| 481 | 481 | ||
| 482 | template <class T> | 482 | template <typename T> |
| 483 | concept match_arg = std::constructible_from<T, std::string const&>; | 483 | concept match_arg = std::constructible_from<T, std::string const&>; |
| 484 | 484 | ||
| 485 | template <class Ctx, match_arg... MatchArgs> | 485 | template <typename Ctx, match_arg... MatchArgs> |
| 486 | using route_handler_fn_t = | 486 | using route_handler_fn_t = |
| 487 | std::function<auto(Ctx, readable_request, MatchArgs...) | 487 | std::function<auto(Ctx, readable_request, MatchArgs...) |
| 488 | ->net::awaitable<presponse>>; | 488 | ->net::awaitable<presponse>>; |
| 489 | 489 | ||
| 490 | template <class Ctx, match_arg... MatchArgs> | 490 | template <typename Ctx, match_arg... MatchArgs> |
| 491 | auto degen_route_handler(route_handler_fn_t<Ctx, MatchArgs...> fn) | 491 | auto degen_route_handler(route_handler_fn_t<Ctx, MatchArgs...> fn) |
| 492 | -> basic_route_handler_fn_t<Ctx> | 492 | -> basic_route_handler_fn_t<Ctx> |
| 493 | { | 493 | { |
| @@ -505,10 +505,10 @@ auto degen_route_handler(route_handler_fn_t<Ctx, MatchArgs...> fn) | |||
| 505 | }; | 505 | }; |
| 506 | } | 506 | } |
| 507 | 507 | ||
| 508 | template <class Ctx, match_arg... MatchArgs> | 508 | template <typename Ctx, match_arg... MatchArgs> |
| 509 | struct ctree : route_tree<Ctx> | 509 | struct ctree : route_tree<Ctx> |
| 510 | { | 510 | { |
| 511 | template <class OuterCtx> | 511 | template <typename OuterCtx> |
| 512 | auto wrap(middleware_t<OuterCtx, Ctx> mw) const | 512 | auto wrap(middleware_t<OuterCtx, Ctx> mw) const |
| 513 | -> ctree<OuterCtx, MatchArgs...> | 513 | -> ctree<OuterCtx, MatchArgs...> |
| 514 | { | 514 | { |
| @@ -516,7 +516,7 @@ struct ctree : route_tree<Ctx> | |||
| 516 | } | 516 | } |
| 517 | }; | 517 | }; |
| 518 | 518 | ||
| 519 | template <class Ctx, match_arg... MatchArgs> | 519 | template <typename Ctx, match_arg... MatchArgs> |
| 520 | struct dtree : handler_map<route_handler_fn_t<Ctx, MatchArgs...>> | 520 | struct dtree : handler_map<route_handler_fn_t<Ctx, MatchArgs...>> |
| 521 | { | 521 | { |
| 522 | [[nodiscard]] auto to_leaves() const -> typename route_tree<Ctx>::leaves | 522 | [[nodiscard]] auto to_leaves() const -> typename route_tree<Ctx>::leaves |
diff --git a/server/src/http/ext/hmac_openssl.cppm b/server/src/http/ext/hmac_openssl.cppm index b196094..a175406 100644 --- a/server/src/http/ext/hmac_openssl.cppm +++ b/server/src/http/ext/hmac_openssl.cppm | |||
| @@ -78,7 +78,6 @@ public: | |||
| 78 | ::EVP_MAC_free(mac_); | 78 | ::EVP_MAC_free(mac_); |
| 79 | } | 79 | } |
| 80 | 80 | ||
| 81 | // TODO: move to impl. unit. | ||
| 82 | auto init(boost::optional<std::uint64_t> n, beast::error_code& ec) noexcept | 81 | auto init(boost::optional<std::uint64_t> n, beast::error_code& ec) noexcept |
| 83 | -> void | 82 | -> void |
| 84 | { | 83 | { |
diff --git a/server/src/http/handler.cpp b/server/src/http/handler.cpp index d755c16..580e3f5 100644 --- a/server/src/http/handler.cpp +++ b/server/src/http/handler.cpp | |||
| @@ -325,7 +325,7 @@ handler::handler( | |||
| 325 | 325 | ||
| 326 | auto handler::make_routes() -> core::route_tree<core::routed_ctx<outer_ctx>> | 326 | auto handler::make_routes() -> core::route_tree<core::routed_ctx<outer_ctx>> |
| 327 | { | 327 | { |
| 328 | auto handler = [this]<class MemFn>(MemFn member) | 328 | auto handler = [this]<typename MemFn>(MemFn member) |
| 329 | { return std::bind_front(member, this); }; | 329 | { return std::bind_front(member, this); }; |
| 330 | 330 | ||
| 331 | return core::dtree<core::routed_ctx<outer_ctx>>{}.named_subtrees({ | 331 | return core::dtree<core::routed_ctx<outer_ctx>>{}.named_subtrees({ |