✨ Adds image route
This commit is contained in:
@@ -4,6 +4,7 @@ mod models;
|
||||
mod schema;
|
||||
|
||||
use crate::api::hit;
|
||||
use crate::api::image;
|
||||
use crate::api::tracker;
|
||||
use diesel::{Connection, PgConnection};
|
||||
use std::env;
|
||||
@@ -16,15 +17,19 @@ fn index() -> &'static str {
|
||||
"Hello world!"
|
||||
}
|
||||
|
||||
// TODO: add logging
|
||||
// TODO: add auth
|
||||
|
||||
#[launch]
|
||||
fn rocket() -> _ {
|
||||
dotenv::dotenv().ok();
|
||||
|
||||
let database_url = env::var("DATABASE_URL").expect("DATABASE_URL must be set");
|
||||
let image_path = env::var("IMAGE_PATH").expect("IMAGE_PATH must be set");
|
||||
let db = PgConnection::establish(&database_url)
|
||||
.expect(&format!("Error connecting to {}", database_url));
|
||||
|
||||
let app_data = models::AppState::new(db);
|
||||
let app_data = models::AppState::new(db, image_path);
|
||||
rocket::build()
|
||||
.manage(app_data)
|
||||
.mount("/", routes![index])
|
||||
@@ -38,4 +43,5 @@ fn rocket() -> _ {
|
||||
],
|
||||
)
|
||||
.mount("/hit", routes![hit::index, hit::get, hit::delete])
|
||||
.mount("/image", routes![image::get])
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user