Skip to content

Commit ff1bb0b

Browse files
committed
Add new router and flat router
1 parent d300f0b commit ff1bb0b

25 files changed

Lines changed: 2878 additions & 3954 deletions

.gitignore

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,24 @@
33
!/build/Jamfile
44
/out/
55
CMakeUserPresets.json
6+
7+
# CMake artifacts (if accidentally run from source dir)
8+
#CMakeCache.txt
9+
#CMakeFiles/
10+
#cmake_install.cmake
11+
#CTestTestfile.cmake
12+
#DartConfiguration.tcl
13+
#build.ninja
14+
#.ninja_deps
15+
#.ninja_log
16+
#*.lib
17+
#Dependencies/
18+
#test/**/cmake_install.cmake
19+
#test/**/CTestTestfile.cmake
20+
#test/**/test_suite/
21+
#test/**/*.cmake
22+
23+
# Build artifacts
24+
#*.exe
25+
#*.pdb
26+
#*.dll

CMakePresets.json

Lines changed: 0 additions & 16 deletions
This file was deleted.

doc/modules/ROOT/pages/server/router.adoc

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ appropriate handlers in order.
4545
4646
using namespace boost::http;
4747
48-
basic_router<route_params> router;
48+
router<route_params> r;
4949
50-
router.add(method::get, "/hello",
50+
r.add(method::get, "/hello",
5151
[](route_params& p)
5252
{
5353
p.status(status::ok);
@@ -232,7 +232,7 @@ Configure matching behavior when constructing the router:
232232

233233
[source,cpp]
234234
----
235-
basic_router<route_params> router(
235+
router<route_params> r(
236236
router_options()
237237
.case_sensitive(true) // Paths are case-sensitive
238238
.strict(true)); // Trailing slash matters
@@ -265,10 +265,10 @@ using namespace boost::http;
265265
266266
int main()
267267
{
268-
basic_router<route_params> router;
268+
router<route_params> r;
269269
270270
// Health check endpoint
271-
router.add(method::get, "/health",
271+
r.add(method::get, "/health",
272272
[](route_params& p)
273273
{
274274
p.status(status::ok);
@@ -277,7 +277,7 @@ int main()
277277
});
278278
279279
// API routes
280-
router.route("/api/echo")
280+
r.route("/api/echo")
281281
.add(method::post,
282282
[](route_params& p)
283283
{
@@ -292,9 +292,10 @@ int main()
292292
return route::send;
293293
});
294294
295-
// Dispatch a request
295+
// Dispatch a request using flat_router
296+
flat_router fr(std::move(r));
296297
route_params p;
297-
auto rv = router.dispatch(
298+
auto rv = co_await fr.dispatch(
298299
method::get,
299300
urls::url_view("/health"),
300301
p);

include/boost/http.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
#include <boost/http/rfc/token_rule.hpp>
4545
#include <boost/http/rfc/upgrade_rule.hpp>
4646

47-
#include <boost/http/server/basic_router.hpp>
4847
#include <boost/http/server/cors.hpp>
4948
#include <boost/http/server/route_handler.hpp>
5049
#include <boost/http/server/router.hpp>

0 commit comments

Comments
 (0)