From e5a34bcba9f59108f7708ef907c2fb6ddb9eff63 Mon Sep 17 00:00:00 2001 From: Steve Gerbino Date: Fri, 1 May 2026 18:36:48 +0200 Subject: [PATCH] Track boost/http router consolidation boost/http removed the separate flat_router class and merged its flattened-dispatch behavior into router. Use http::router directly in http_worker, http_server, https_server, and the example server. --- example/server/main.cpp | 8 +++----- example/server/serve_log_admin.hpp | 2 +- include/boost/beast2/http_server.hpp | 6 +++--- include/boost/beast2/http_worker.hpp | 7 +++---- include/boost/beast2/https_server.hpp | 6 +++--- src/http_server.cpp | 8 +++----- src/http_worker.cpp | 2 +- src/https_server.cpp | 8 +++----- 8 files changed, 20 insertions(+), 27 deletions(-) diff --git a/example/server/main.cpp b/example/server/main.cpp index 1ab521eb..4999a6cc 100644 --- a/example/server/main.cpp +++ b/example/server/main.cpp @@ -20,7 +20,6 @@ #include #include #include -#include #include #include #include @@ -128,7 +127,7 @@ void install_services() #endif } -class application : public http::router +class application : public http::router { struct impl; impl* impl_; @@ -136,7 +135,6 @@ class application : public http::router public: void listen(unsigned short) { - http::flat_router fr(std::move(*this)); } }; @@ -188,7 +186,7 @@ int server_main( int argc, char* argv[] ) co_return http::route_done; }); #endif - http_server hs1(ioc, 40, http::flat_router(std::move(rr1)), + http_server hs1(ioc, 40, std::move(rr1), http::make_parser_config(http::parser_config(true)), http::make_serializer_config(http::serializer_config())); auto ec = hs1.bind(corosio::endpoint(ep, 80)); @@ -206,7 +204,7 @@ int server_main( int argc, char* argv[] ) rr2.use( http::cors() ); rr2.use( "/", http::serve_static( argv[2] ) ); https_server hs2(ioc, std::atoi(argv[1]), tls, - http::flat_router(std::move(rr2)), + std::move(rr2), http::make_parser_config(http::parser_config(true)), http::make_serializer_config(http::serializer_config())); ec = hs2.bind(corosio::endpoint(ep, 443)); diff --git a/example/server/serve_log_admin.hpp b/example/server/serve_log_admin.hpp index 50218556..b0932144 100644 --- a/example/server/serve_log_admin.hpp +++ b/example/server/serve_log_admin.hpp @@ -16,7 +16,7 @@ namespace boost { namespace beast2 { -http::router +http::router serve_log_admin(); } // beast2 diff --git a/include/boost/beast2/http_server.hpp b/include/boost/beast2/http_server.hpp index d1eb63c2..813a7404 100644 --- a/include/boost/beast2/http_server.hpp +++ b/include/boost/beast2/http_server.hpp @@ -14,10 +14,10 @@ #include #include #include +#include #include namespace boost { -namespace http { class flat_router; } namespace beast2 { /** An HTTP server for handling requests with coroutine-based I/O. @@ -34,7 +34,7 @@ namespace beast2 { @par Example @code corosio::io_context ctx; - http::flat_router router; + http::router router; router.add( http::verb::get, "/", my_handler ); http_server srv( @@ -73,7 +73,7 @@ class BOOST_BEAST2_DECL http_server( corosio::io_context& ctx, std::size_t num_workers, - http::flat_router router, + http::router router, http::shared_parser_config parser_cfg, http::shared_serializer_config serializer_cfg); }; diff --git a/include/boost/beast2/http_worker.hpp b/include/boost/beast2/http_worker.hpp index 4d59df20..c7a51fa2 100644 --- a/include/boost/beast2/http_worker.hpp +++ b/include/boost/beast2/http_worker.hpp @@ -16,7 +16,6 @@ #include #include #include -#include #include namespace boost { @@ -51,7 +50,7 @@ namespace beast2 { my_worker( corosio::io_context& ctx, - http::flat_router const& router, + http::router const& router, http::shared_parser_config parser_cfg, http::shared_serializer_config serializer_cfg) : http_worker(router, parser_cfg, serializer_cfg) @@ -81,7 +80,7 @@ namespace beast2 { class BOOST_BEAST2_DECL http_worker { public: - http::flat_router fr; + http::router fr; http::route_params rp; capy::any_read_stream stream; http::request_parser parser; @@ -95,7 +94,7 @@ class BOOST_BEAST2_DECL http_worker serializer. */ http_worker( - http::flat_router fr_, + http::router fr_, http::shared_parser_config parser_cfg, http::shared_serializer_config serializer_cfg); diff --git a/include/boost/beast2/https_server.hpp b/include/boost/beast2/https_server.hpp index fb75a650..434df2af 100644 --- a/include/boost/beast2/https_server.hpp +++ b/include/boost/beast2/https_server.hpp @@ -15,10 +15,10 @@ #include #include #include +#include #include namespace boost { -namespace http { class flat_router; } namespace beast2 { /** An HTTPS server for handling requests with coroutine-based I/O. @@ -42,7 +42,7 @@ namespace beast2 { tls_ctx.use_certificate_chain_file("server.crt", corosio::tls_file_format::pem); tls_ctx.use_private_key_file("server.key", corosio::tls_file_format::pem); - http::flat_router router; + http::router router; router.add( http::verb::get, "/", my_handler ); https_server srv( @@ -86,7 +86,7 @@ class BOOST_BEAST2_DECL corosio::io_context& ctx, std::size_t num_workers, corosio::tls_context tls_ctx, - http::flat_router router, + http::router router, http::shared_parser_config parser_cfg, http::shared_serializer_config serializer_cfg); }; diff --git a/src/http_server.cpp b/src/http_server.cpp index 81972756..bd76b4e3 100644 --- a/src/http_server.cpp +++ b/src/http_server.cpp @@ -9,7 +9,6 @@ #include #include -#include #include #include #include @@ -21,7 +20,6 @@ #include #include #include -#include #include #include #include @@ -31,11 +29,11 @@ namespace beast2 { struct http_server::impl { - http::flat_router router; + http::router router; http::shared_parser_config parser_cfg; http::shared_serializer_config serializer_cfg; - impl(http::flat_router r) + impl(http::router r) : router(std::move(r)) { } @@ -99,7 +97,7 @@ http_server:: http_server( corosio::io_context& ctx, std::size_t num_workers, - http::flat_router router, + http::router router, http::shared_parser_config parser_cfg, http::shared_serializer_config serializer_cfg) : tcp_server(ctx, ctx.get_executor()) diff --git a/src/http_worker.cpp b/src/http_worker.cpp index aacbd5db..aa54b361 100644 --- a/src/http_worker.cpp +++ b/src/http_worker.cpp @@ -17,7 +17,7 @@ namespace beast2 { http_worker:: http_worker( - http::flat_router fr_, + http::router fr_, http::shared_parser_config parser_cfg, http::shared_serializer_config serializer_cfg) : fr(std::move(fr_)) diff --git a/src/https_server.cpp b/src/https_server.cpp index 28baef26..42f5b019 100644 --- a/src/https_server.cpp +++ b/src/https_server.cpp @@ -9,7 +9,6 @@ #include #include -#include #include #include #include @@ -22,7 +21,6 @@ #include #include #include -#include #include #include #include @@ -34,13 +32,13 @@ namespace beast2 { struct https_server::impl { corosio::tls_context tls_ctx; - http::flat_router router; + http::router router; http::shared_parser_config parser_cfg; http::shared_serializer_config serializer_cfg; impl( corosio::tls_context tc, - http::flat_router r) + http::router r) : tls_ctx(std::move(tc)) , router(std::move(r)) { @@ -132,7 +130,7 @@ https_server( corosio::io_context& ctx, std::size_t num_workers, corosio::tls_context tls_ctx, - http::flat_router router, + http::router router, http::shared_parser_config parser_cfg, http::shared_serializer_config serializer_cfg) : tcp_server(ctx, ctx.get_executor())