![]() |
boost::taar::handler::with_session — Bind a keyed context to a handler.
// In header: <boost/taar/handler/with_session.hpp> template<typename Key, typename Context, typename KeyExtractor, typename Inner> auto with_session(context_store< Key, Context > & store, KeyExtractor key, session_policy policy, Inner inner);
taar::context_store<std::string, cart> carts {std::chrono::minutes {30}}; session.register_request_handler( method == http::verb::post && target == "/cart/items", taar::handler::with_session(carts, taar::handler::session_key::cookie("sid"), taar::handler::session_policy::create_if_missing, taar::handler::rest(&add_item, json_body_arg()))); // add_item(cart&, json::value)
Parameters: |
|