use crate::model;
use crate::data::{db, asynchronous};
+mod api;
+
///// UTILS /////
fn get_ip_and_user_agent(req: &HttpRequest) -> (String, String) {
#[template(path = "home.html")]
struct HomeTemplate {
user: Option<User>,
- recipes: Vec<(i32, String)>,
- current_recipe_id: Option<i32>,
+ recipes: Vec<(i64, String)>,
+ current_recipe_id: Option<i64>,
}
#[get("/")]
#[template(path = "view_recipe.html")]
struct ViewRecipeTemplate {
user: Option<User>,
- recipes: Vec<(i32, String)>,
- current_recipe_id: Option<i32>,
+ recipes: Vec<(i64, String)>,
+ current_recipe_id: Option<i64>,
current_recipe: model::Recipe,
}
#[get("/recipe/view/{id}")]
-pub async fn view_recipe(req: HttpRequest, path: web::Path<(i32,)>, connection: web::Data<db::Connection>) -> Result<HttpResponse> {
+pub async fn view_recipe(req: HttpRequest, path: web::Path<(i64,)>, connection: web::Data<db::Connection>) -> Result<HttpResponse> {
let (id,)= path.into_inner();
let user = get_current_user(&req, connection.clone()).await;
let recipes = connection.get_all_recipe_titles_async().await?;
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<i32> = 'p: {
+ let port: Option<u16> = 'p: {
let split_port: Vec<&str> = host.split(':').collect();
if split_port.len() == 2 {
- if let Ok(p) = split_port[1].parse::<i32>() {
+ if let Ok(p) = split_port[1].parse::<u16>() {
break 'p Some(p)
}
}