-mod db;
-
-#[derive(Template)]
-#[template(path = "home.html")]
-struct HomeTemplate {
- recipes: Vec<(i32, String)>,
-}
-
-#[derive(Template)]
-#[template(path = "view_recipe.html")]
-struct ViewRecipeTemplate {
- recipes: Vec<(i32, String)>,
- current_recipe: model::Recipe,
-}
-
-#[derive(Deserialize)]
-pub struct Request {
- m: Option<String>
-}
-
-#[get("/")]
-async fn home_page(req: HttpRequest, connection: web::Data<db::Connection>) -> impl Responder {
- HomeTemplate { recipes: connection.get_all_recipe_titles().unwrap() } // TODO: unwrap.
-}
-
-#[get("/recipe/view/{id}")]
-async fn view_recipe(req: HttpRequest, path: web::Path<(i32,)>, connection: web::Data<db::Connection>) -> impl Responder {
- ViewRecipeTemplate {
- recipes: connection.get_all_recipe_titles().unwrap(),
- current_recipe: connection.get_recipe(path.0).unwrap(),
- }
-}
-
-#[derive(Debug, Deserialize)]
-struct Config {
- port: u16
-}
-
-fn get_exe_name() -> String {
- let first_arg = std::env::args().nth(0).unwrap();
- let sep: &[_] = &['\\', '/'];
- first_arg[first_arg.rfind(sep).unwrap()+1..].to_string()
-}