wip
This commit is contained in:
@@ -1,18 +1,31 @@
|
||||
use rocket::{get, State};
|
||||
use rocket_dyn_templates::Template;
|
||||
use log::error;
|
||||
use ovlach_data::cv::cv::CV;
|
||||
use rocket::{get, State, response::status::NotFound, http::Status};
|
||||
use rocket_dyn_templates::{Template, context};
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::PresentationConfig;
|
||||
use crate::{PresentationConfig, services::cv::fetch_cv_data_from_backend, CVBackendConfig};
|
||||
|
||||
#[derive(Serialize, Debug)]
|
||||
struct RootPage {
|
||||
static_host: String,
|
||||
cv: CV
|
||||
}
|
||||
|
||||
#[get("/")]
|
||||
pub fn index(config: &State<PresentationConfig>) -> Template {
|
||||
let context = RootPage {
|
||||
static_host: config.static_route.clone(),
|
||||
pub async fn index(presentation_config: &State<PresentationConfig>, cv_config: &State<CVBackendConfig>) -> Result<Template, Status> {
|
||||
let context = match fetch_cv_data_from_backend(cv_config.cv_backend_path.clone()).await {
|
||||
Ok(cv) => RootPage {
|
||||
static_host: presentation_config.static_route.clone(),
|
||||
cv
|
||||
},
|
||||
Err(e) => {
|
||||
error!("Can't fetch CV data from backend {:?}", e);
|
||||
return Err(Status::InternalServerError)
|
||||
}
|
||||
};
|
||||
Template::render("default", &context)
|
||||
|
||||
//return Templ;
|
||||
|
||||
Ok(Template::render("default", &context))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user