diff options
Diffstat (limited to 'server/src/http_server.cppm')
| -rw-r--r-- | server/src/http_server.cppm | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/server/src/http_server.cppm b/server/src/http_server.cppm index 12c83db..2bf3c63 100644 --- a/server/src/http_server.cppm +++ b/server/src/http_server.cppm | |||
| @@ -200,7 +200,7 @@ auto cors_middleware(std::vector<std::string> const& allow_origins) | |||
| 200 | } | 200 | } |
| 201 | 201 | ||
| 202 | template <class Ctx> | 202 | template <class Ctx> |
| 203 | auto trace_id_middleware( | 203 | auto expose_trace_id_middleware( |
| 204 | Ctx ctx, bhttp::request_header<bhttp::fields>& req_hdr, | 204 | Ctx ctx, bhttp::request_header<bhttp::fields>& req_hdr, |
| 205 | next_handler_t<Ctx> next) -> net::awaitable<presponse> | 205 | next_handler_t<Ctx> next) -> net::awaitable<presponse> |
| 206 | { | 206 | { |
| @@ -214,6 +214,24 @@ auto trace_id_middleware( | |||
| 214 | co_return std::move(prersp); | 214 | co_return std::move(prersp); |
| 215 | } | 215 | } |
| 216 | 216 | ||
| 217 | template <class Ctx> | ||
| 218 | auto expose_content_language_middleware( | ||
| 219 | Ctx ctx, bhttp::request_header<bhttp::fields>& req_hdr, | ||
| 220 | next_handler_t<Ctx> next) -> net::awaitable<presponse> | ||
| 221 | { | ||
| 222 | std::ignore = req_hdr; | ||
| 223 | auto prersp = co_await next(std::move(ctx)); | ||
| 224 | if (prersp.header().find(bhttp::field::content_language) | ||
| 225 | == prersp.header().end() | ||
| 226 | && std::has_facet<locale::bcp47_tag>(ctx.locale)) | ||
| 227 | { | ||
| 228 | prersp.header().set( | ||
| 229 | bhttp::field::content_language, | ||
| 230 | std::use_facet<locale::bcp47_tag>(ctx.locale).tag()); | ||
| 231 | } | ||
| 232 | co_return std::move(prersp); | ||
| 233 | } | ||
| 234 | |||
| 217 | struct keep_alive | 235 | struct keep_alive |
| 218 | { | 236 | { |
| 219 | bool value; | 237 | bool value; |