diff options
| author | Rutger Broekhoff | 2026-08-28 18:03:05 +0200 |
|---|---|---|
| committer | Rutger Broekhoff | 2026-08-28 18:03:05 +0200 |
| commit | 973aec43ea54bbf95b64fbcb636403401d1ca60e (patch) | |
| tree | 41b7911c420766a9b463245b9296f44c5bf35258 /server/src/req_ctx.cppm | |
| download | routemon-973aec43ea54bbf95b64fbcb636403401d1ca60e.tar.gz routemon-973aec43ea54bbf95b64fbcb636403401d1ca60e.zip | |
Import from e4b104792206ee7ea64bf39c6b7d2c0c230f9d14
Diffstat (limited to 'server/src/req_ctx.cppm')
| -rw-r--r-- | server/src/req_ctx.cppm | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/server/src/req_ctx.cppm b/server/src/req_ctx.cppm new file mode 100644 index 0000000..797c51d --- /dev/null +++ b/server/src/req_ctx.cppm | |||
| @@ -0,0 +1,51 @@ | |||
| 1 | module; | ||
| 2 | |||
| 3 | #include <boost/beast/http/message.hpp> | ||
| 4 | #include <boost/beast/http/verb.hpp> | ||
| 5 | |||
| 6 | export module routemon:req_ctx; | ||
| 7 | |||
| 8 | import :http.common; | ||
| 9 | import :trace; | ||
| 10 | |||
| 11 | namespace routemon { | ||
| 12 | |||
| 13 | export class req_ctx { | ||
| 14 | trace::id tid_; | ||
| 15 | std::locale locale_; | ||
| 16 | http::verb_set route_verbs_; | ||
| 17 | bool keep_alive_; | ||
| 18 | bhttp::request_header<bhttp::fields> const& req_header_; | ||
| 19 | |||
| 20 | public: | ||
| 21 | explicit req_ctx(trace::id tid, std::locale locale, http::verb_set route_verbs, bool keep_alive, bhttp::request_header<bhttp::fields> const& req_header) | ||
| 22 | : tid_{tid}, locale_{locale}, route_verbs_{route_verbs}, keep_alive_{keep_alive}, req_header_{req_header} | ||
| 23 | {} | ||
| 24 | |||
| 25 | template<typename ReqBody> | ||
| 26 | explicit req_ctx(trace::id tid, std::locale locale, http::verb_set route_verbs, bhttp::request<ReqBody> const& req) | ||
| 27 | : req_ctx{tid, locale, route_verbs, req.keep_alive(), req.base()} | ||
| 28 | {} | ||
| 29 | |||
| 30 | auto trace_id() const -> trace::id { | ||
| 31 | return tid_; | ||
| 32 | } | ||
| 33 | |||
| 34 | auto locale() const -> std::locale { | ||
| 35 | return locale_; | ||
| 36 | } | ||
| 37 | |||
| 38 | auto route_verbs() const -> http::verb_set { | ||
| 39 | return route_verbs_; | ||
| 40 | } | ||
| 41 | |||
| 42 | auto keep_alive() const -> bool { | ||
| 43 | return keep_alive_; | ||
| 44 | } | ||
| 45 | |||
| 46 | auto req_header() const -> bhttp::request_header<bhttp::fields> const& { | ||
| 47 | return req_header_; | ||
| 48 | } | ||
| 49 | }; | ||
| 50 | |||
| 51 | } // namespace routemon | ||