Skip to content

Commit 5b46177

Browse files
committed
[FOLD]
1 parent 509280d commit 5b46177

2 files changed

Lines changed: 17 additions & 17 deletions

File tree

include/boost/http_proto/server/route_handler.hpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,13 @@ struct Request : basic_request
5656
/** A container for storing arbitrary data associated with the request.
5757
This starts out empty for each new request.
5858
*/
59-
capy::datastore data;
59+
capy::datastore route_data;
60+
61+
/** A container for storing arbitrary data associated with the session.
62+
63+
This starts out empty for each new session.
64+
*/
65+
capy::datastore session_data;
6066
};
6167

6268
//-----------------------------------------------
@@ -81,12 +87,6 @@ struct BOOST_SYMBOL_VISIBLE
8187
*/
8288
detacher detach;
8389

84-
/** A container for storing arbitrary data associated with the session.
85-
86-
This starts out empty for each new session.
87-
*/
88-
capy::datastore data;
89-
9090
/** Constructor.
9191
*/
9292
BOOST_HTTP_PROTO_DECL

test/unit/server/route_handler.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,37 +53,37 @@ struct route_handler_test
5353

5454
test_router r;
5555
r.use(
56-
[](Request&, Response& res)
56+
[](Request& req, Response&)
5757
{
5858
// create session_token
59-
auto& st = res.data.try_emplace<session_token>();
59+
auto& st = req.session_data.try_emplace<session_token>();
6060
BOOST_TEST_EQ(st.valid, false);
6161
return route::next;
6262
});
6363
r.use("/user",
64-
[](Request&, Response& res)
64+
[](Request& req, Response&)
6565
{
6666
// make session token valid
67-
auto* st = res.data.find<session_token>();
67+
auto* st = req.session_data.find<session_token>();
6868
if(BOOST_TEST_NE(st, nullptr))
6969
st->valid = true;
7070
return route::next;
7171
});
7272
r.route("/user/auth")
7373
.add(POST,
74-
[](Request& req, Response& res)
74+
[](Request& req, Response&)
7575
{
76-
auto& st = res.data.get<session_token>();
76+
auto& st = req.session_data.get<session_token>();
7777
BOOST_TEST_EQ(st.valid, true);
7878
// create auth_token each time
79-
auto& at = req.data.emplace<auth_token>();
79+
auto& at = req.route_data.emplace<auth_token>();
8080
at.valid = true;
8181
return route::next;
8282
},
83-
[](Request& req, Response& res)
83+
[](Request& req, Response&)
8484
{
85-
auto& at = req.data.get<auth_token>();
86-
auto& st = res.data.get<session_token>();
85+
auto& at = req.route_data.get<auth_token>();
86+
auto& st = req.session_data.get<session_token>();
8787
BOOST_TEST_EQ(at.valid, true);
8888
BOOST_TEST_EQ(st.valid, true);
8989
return route::send;

0 commit comments

Comments
 (0)