Skip to content

Commit 7d7644a

Browse files
committed
Track boost/http router consolidation
boost/http removed the separate flat_router class and merged its flattened-dispatch behavior into router<P, HT>. Use http::router<http::route_params> directly in http_worker, http_server, https_server, and the example server.
1 parent 276d4d0 commit 7d7644a

8 files changed

Lines changed: 20 additions & 27 deletions

File tree

‎example/server/main.cpp‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
#include <boost/capy/read.hpp>
2121
#include <boost/corosio/signal_set.hpp>
2222
#include <boost/http/json/json_sink.hpp>
23-
#include <boost/http/server/flat_router.hpp>
2423
#include <boost/http/server/serve_static.hpp>
2524
#include <boost/http/request_parser.hpp>
2625
#include <boost/http/serializer.hpp>
@@ -128,15 +127,14 @@ void install_services()
128127
#endif
129128
}
130129

131-
class application : public http::router
130+
class application : public http::router<http::route_params>
132131
{
133132
struct impl;
134133
impl* impl_;
135134

136135
public:
137136
void listen(unsigned short)
138137
{
139-
http::flat_router fr(std::move(*this));
140138
}
141139
};
142140

@@ -188,7 +186,7 @@ int server_main( int argc, char* argv[] )
188186
co_return http::route_done;
189187
});
190188
#endif
191-
http_server hs1(ioc, 40, http::flat_router(std::move(rr1)),
189+
http_server hs1(ioc, 40, std::move(rr1),
192190
http::make_parser_config(http::parser_config(true)),
193191
http::make_serializer_config(http::serializer_config()));
194192
auto ec = hs1.bind(corosio::endpoint(ep, 80));
@@ -206,7 +204,7 @@ int server_main( int argc, char* argv[] )
206204
rr2.use( http::cors() );
207205
rr2.use( "/", http::serve_static( argv[2] ) );
208206
https_server hs2(ioc, std::atoi(argv[1]), tls,
209-
http::flat_router(std::move(rr2)),
207+
std::move(rr2),
210208
http::make_parser_config(http::parser_config(true)),
211209
http::make_serializer_config(http::serializer_config()));
212210
ec = hs2.bind(corosio::endpoint(ep, 443));

‎example/server/serve_log_admin.hpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
namespace boost {
1717
namespace beast2 {
1818

19-
http::router
19+
http::router<http::route_params>
2020
serve_log_admin();
2121

2222
} // beast2

‎include/boost/beast2/http_server.hpp‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414
#include <boost/corosio/tcp_server.hpp>
1515
#include <boost/corosio/io_context.hpp>
1616
#include <boost/http/config.hpp>
17+
#include <boost/http/server/router.hpp>
1718
#include <cstddef>
1819

1920
namespace boost {
20-
namespace http { class flat_router; }
2121
namespace beast2 {
2222

2323
/** An HTTP server for handling requests with coroutine-based I/O.
@@ -34,7 +34,7 @@ namespace beast2 {
3434
@par Example
3535
@code
3636
corosio::io_context ctx;
37-
http::flat_router router;
37+
http::router<http::route_params> router;
3838
router.add( http::verb::get, "/", my_handler );
3939
4040
http_server srv(
@@ -73,7 +73,7 @@ class BOOST_BEAST2_DECL
7373
http_server(
7474
corosio::io_context& ctx,
7575
std::size_t num_workers,
76-
http::flat_router router,
76+
http::router<http::route_params> router,
7777
http::shared_parser_config parser_cfg,
7878
http::shared_serializer_config serializer_cfg);
7979
};

‎include/boost/beast2/http_worker.hpp‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#include <boost/http/config.hpp>
1717
#include <boost/http/request_parser.hpp>
1818
#include <boost/http/serializer.hpp>
19-
#include <boost/http/server/flat_router.hpp>
2019
#include <boost/http/server/router.hpp>
2120

2221
namespace boost {
@@ -51,7 +50,7 @@ namespace beast2 {
5150
5251
my_worker(
5352
corosio::io_context& ctx,
54-
http::flat_router const& router,
53+
http::router<http::route_params> const& router,
5554
http::shared_parser_config parser_cfg,
5655
http::shared_serializer_config serializer_cfg)
5756
: http_worker(router, parser_cfg, serializer_cfg)
@@ -81,7 +80,7 @@ namespace beast2 {
8180
class BOOST_BEAST2_DECL http_worker
8281
{
8382
public:
84-
http::flat_router fr;
83+
http::router<http::route_params> fr;
8584
http::route_params rp;
8685
capy::any_read_stream stream;
8786
http::request_parser parser;
@@ -95,7 +94,7 @@ class BOOST_BEAST2_DECL http_worker
9594
serializer.
9695
*/
9796
http_worker(
98-
http::flat_router fr_,
97+
http::router<http::route_params> fr_,
9998
http::shared_parser_config parser_cfg,
10099
http::shared_serializer_config serializer_cfg);
101100

‎include/boost/beast2/https_server.hpp‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
#include <boost/corosio/io_context.hpp>
1616
#include <boost/corosio/tls_context.hpp>
1717
#include <boost/http/config.hpp>
18+
#include <boost/http/server/router.hpp>
1819
#include <cstddef>
1920

2021
namespace boost {
21-
namespace http { class flat_router; }
2222
namespace beast2 {
2323

2424
/** An HTTPS server for handling requests with coroutine-based I/O.
@@ -42,7 +42,7 @@ namespace beast2 {
4242
tls_ctx.use_certificate_chain_file("server.crt", corosio::tls_file_format::pem);
4343
tls_ctx.use_private_key_file("server.key", corosio::tls_file_format::pem);
4444
45-
http::flat_router router;
45+
http::router<http::route_params> router;
4646
router.add( http::verb::get, "/", my_handler );
4747
4848
https_server srv(
@@ -86,7 +86,7 @@ class BOOST_BEAST2_DECL
8686
corosio::io_context& ctx,
8787
std::size_t num_workers,
8888
corosio::tls_context tls_ctx,
89-
http::flat_router router,
89+
http::router<http::route_params> router,
9090
http::shared_parser_config parser_cfg,
9191
http::shared_serializer_config serializer_cfg);
9292
};

‎src/http_server.cpp‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
#include <boost/beast2/http_server.hpp>
1111
#include <boost/beast2/http_worker.hpp>
12-
#include <boost/http/server/flat_router.hpp>
1312
#include <boost/capy/task.hpp>
1413
#include <boost/capy/cond.hpp>
1514
#include <boost/capy/ex/strand.hpp>
@@ -21,7 +20,6 @@
2120
#include <boost/http/server/router.hpp>
2221
#include <boost/http/serializer.hpp>
2322
#include <boost/http/string_body.hpp>
24-
#include <boost/http/server/basic_router.hpp>
2523
#include <boost/http/error.hpp>
2624
#include <boost/url/parse.hpp>
2725
#include <iostream>
@@ -31,11 +29,11 @@ namespace beast2 {
3129

3230
struct http_server::impl
3331
{
34-
http::flat_router router;
32+
http::router<http::route_params> router;
3533
http::shared_parser_config parser_cfg;
3634
http::shared_serializer_config serializer_cfg;
3735

38-
impl(http::flat_router r)
36+
impl(http::router<http::route_params> r)
3937
: router(std::move(r))
4038
{
4139
}
@@ -99,7 +97,7 @@ http_server::
9997
http_server(
10098
corosio::io_context& ctx,
10199
std::size_t num_workers,
102-
http::flat_router router,
100+
http::router<http::route_params> router,
103101
http::shared_parser_config parser_cfg,
104102
http::shared_serializer_config serializer_cfg)
105103
: tcp_server(ctx, ctx.get_executor())

‎src/http_worker.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ namespace beast2 {
1717

1818
http_worker::
1919
http_worker(
20-
http::flat_router fr_,
20+
http::router<http::route_params> fr_,
2121
http::shared_parser_config parser_cfg,
2222
http::shared_serializer_config serializer_cfg)
2323
: fr(std::move(fr_))

‎src/https_server.cpp‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
#include <boost/beast2/https_server.hpp>
1111
#include <boost/beast2/http_worker.hpp>
12-
#include <boost/http/server/flat_router.hpp>
1312
#include <boost/capy/task.hpp>
1413
#include <boost/capy/cond.hpp>
1514
#include <boost/capy/ex/strand.hpp>
@@ -22,7 +21,6 @@
2221
#include <boost/http/server/router.hpp>
2322
#include <boost/http/serializer.hpp>
2423
#include <boost/http/string_body.hpp>
25-
#include <boost/http/server/basic_router.hpp>
2624
#include <boost/http/error.hpp>
2725
#include <boost/url/parse.hpp>
2826
#include <iostream>
@@ -34,13 +32,13 @@ namespace beast2 {
3432
struct https_server::impl
3533
{
3634
corosio::tls_context tls_ctx;
37-
http::flat_router router;
35+
http::router<http::route_params> router;
3836
http::shared_parser_config parser_cfg;
3937
http::shared_serializer_config serializer_cfg;
4038

4139
impl(
4240
corosio::tls_context tc,
43-
http::flat_router r)
41+
http::router<http::route_params> r)
4442
: tls_ctx(std::move(tc))
4543
, router(std::move(r))
4644
{
@@ -132,7 +130,7 @@ https_server(
132130
corosio::io_context& ctx,
133131
std::size_t num_workers,
134132
corosio::tls_context tls_ctx,
135-
http::flat_router router,
133+
http::router<http::route_params> router,
136134
http::shared_parser_config parser_cfg,
137135
http::shared_serializer_config serializer_cfg)
138136
: tcp_server(ctx, ctx.get_executor())

0 commit comments

Comments
 (0)