(req: &HttpRequest)
| 15 | |
| 16 | impl LangChoice { |
| 17 | pub(crate) fn from_req(req: &HttpRequest) -> Self { |
| 18 | let lang = req |
| 19 | .get_header::<AcceptLanguage>() |
| 20 | .and_then(|lang| lang.preference().into_item()) |
| 21 | .map_or_else(|| "en".to_owned(), |lang| lang.to_string()); |
| 22 | |
| 23 | Self(lang) |
| 24 | } |
| 25 | |
| 26 | pub fn lang_id(&self) -> LanguageIdentifier { |
| 27 | // unwrap: lang ID should be valid given extraction method |
nothing calls this directly
no outgoing calls
no test coverage detected