This commit is contained in:
2023-12-03 17:30:27 +01:00
parent 2b133a9f3f
commit 32a9ed081e
4 changed files with 97 additions and 11 deletions

View File

@@ -8,27 +8,29 @@ use rocket::{get, State, response::Redirect, http::Status, futures::executor::en
use rocket_dyn_templates::Template;
use serde::Serialize;
use crate::{PresentationConfig, services::cv::fetch_cv_data_from_backend, CVBackendConfig, tools::rocket::RequestLanguage, DefaultPerson};
use crate::{PresentationConfig, services::cv::fetch_cv_data_from_backend, CVBackendConfig, tools::rocket::RequestLanguage, DefaultPerson, FrontendSVCConfig};
#[derive(Serialize, Debug)]
struct RootPage {
static_host: String,
cv: CV,
download_cv_url: String,
lang: LanguageDescription,
contact_svc: String,
pdf_download_url: String
}
#[get("/<language>")]
pub async fn index(presentation_config: &State<PresentationConfig>, cv_config: &State<CVBackendConfig>, language: RequestLanguage, client: OtelReqwestClient,
default_person: &State<DefaultPerson>, span: TracingSpan) -> Result<Template, Status> {
default_person: &State<DefaultPerson>, frontend_svc: &State<FrontendSVCConfig>, span: TracingSpan) -> Result<Template, Status> {
let span = span.0.enter();
let context = match fetch_cv_data_from_backend(&cv_config.cv_backend_path, &default_person.default_person_name, &client.0).await {
Ok(cv) => RootPage {
static_host: presentation_config.static_route.clone(),
cv,
download_cv_url: "FIXME!".to_string(),
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)
},
Err(e) => {
error!("Can't fetch CV data from backend {:?}", e);