fix: link to pdf
This commit is contained in:
parent
f5fec79296
commit
5af90d846c
@ -28,7 +28,7 @@ default_person: &State<DefaultPerson>, frontend_svc: &State<FrontendSVCConfig>,
|
||||
cv,
|
||||
lang: LanguageDescription::new(language.language.as_str(), "ovlach_frontend"),
|
||||
contact_svc: frontend_svc.inner().contact_service.clone(),
|
||||
pdf_download_url: format!("{}/cv/{}/output.pdf", frontend_svc.inner().pdf_service.clone(), default_person.default_person_name)
|
||||
pdf_download_url: format!("{}/cv/{}/{}/output.pdf", frontend_svc.inner().pdf_service.clone(), default_person.default_person_name, language.language) // route: /cv/<username>/<language>/output.pdf
|
||||
},
|
||||
Err(e) => {
|
||||
error!("Can't fetch CV data from backend {:?}", e);
|
||||
|
@ -4,6 +4,13 @@ use phf::phf_map;
|
||||
|
||||
pub struct RequestLanguage {
|
||||
pub language: String,
|
||||
pub simple_language: String,
|
||||
}
|
||||
|
||||
|
||||
fn find_key_for_value<'a>(map: &'a phf::Map<&'a str, &'a str>, value: &str) -> Option<&'a str> {
|
||||
map.into_iter()
|
||||
.find_map(|(key, &val)| if val == value { Some(*key) } else { None })
|
||||
}
|
||||
|
||||
static LANG_TO_CODES: phf::Map<&'static str, &'static str> = phf_map! {
|
||||
@ -18,9 +25,11 @@ impl<'r> FromParam<'r> for RequestLanguage {
|
||||
match LANG_TO_CODES.get(param) {
|
||||
Some(val) => Ok(RequestLanguage {
|
||||
language: val.to_string(),
|
||||
simple_language: find_key_for_value(&LANG_TO_CODES, val).unwrap_or("un").to_string(),
|
||||
}),
|
||||
None => Ok(RequestLanguage {
|
||||
language: LANG_TO_CODES["en"].to_string(),
|
||||
simple_language: "en".to_string(),
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user