X-Git-Url: http://git.euphorik.ch/?p=recipes.git;a=blobdiff_plain;f=backend%2Fsrc%2Fservices.rs;fp=backend%2Fsrc%2Fservices.rs;h=2d69cc5fafdf31d843c0370697768bb50f3c760c;hp=df81c437b0224d098461a761704df75c54f57d1a;hb=642dd8a80ce2e1212b8e30c1edabb32bdb416cfc;hpb=d28e765e39e70ad2ab9a42885c786d5d8ba9ba40 diff --git a/backend/src/services.rs b/backend/src/services.rs index df81c43..2d69cc5 100644 --- a/backend/src/services.rs +++ b/backend/src/services.rs @@ -14,6 +14,8 @@ use crate::user::User; use crate::model; use crate::data::{db, asynchronous}; +mod api; + ///// UTILS ///// fn get_ip_and_user_agent(req: &HttpRequest) -> (String, String) { @@ -119,8 +121,8 @@ impl actix_web::error::ResponseError for ServiceError { #[template(path = "home.html")] struct HomeTemplate { user: Option, - recipes: Vec<(i32, String)>, - current_recipe_id: Option, + recipes: Vec<(i64, String)>, + current_recipe_id: Option, } #[get("/")] @@ -137,13 +139,13 @@ pub async fn home_page(req: HttpRequest, connection: web::Data) #[template(path = "view_recipe.html")] struct ViewRecipeTemplate { user: Option, - recipes: Vec<(i32, String)>, - current_recipe_id: Option, + recipes: Vec<(i64, String)>, + current_recipe_id: Option, current_recipe: model::Recipe, } #[get("/recipe/view/{id}")] -pub async fn view_recipe(req: HttpRequest, path: web::Path<(i32,)>, connection: web::Data) -> Result { +pub async fn view_recipe(req: HttpRequest, path: web::Path<(i64,)>, connection: web::Data) -> Result { let (id,)= path.into_inner(); let user = get_current_user(&req, connection.clone()).await; let recipes = connection.get_all_recipe_titles_async().await?; @@ -255,10 +257,10 @@ pub async fn sign_up_post(req: HttpRequest, form: web::Form, con Ok(db::SignUpResult::UserCreatedWaitingForValidation(token)) => { let url = { let host = req.headers().get(header::HOST).map(|v| v.to_str().unwrap_or_default()).unwrap_or_default(); - let port: Option = 'p: { + let port: Option = 'p: { let split_port: Vec<&str> = host.split(':').collect(); if split_port.len() == 2 { - if let Ok(p) = split_port[1].parse::() { + if let Ok(p) = split_port[1].parse::() { break 'p Some(p) } }