diff --git a/.env b/.env index 77e3b5d..5ec33c0 100644 --- a/.env +++ b/.env @@ -1 +1,2 @@ +# This is usually used in development by sqlx. It is not used in production DATABASE_URL=sqlite://emgauwa-core.sqlite diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..718cf25 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,3 @@ +* text=auto + +Cargo.lock -diff diff --git a/Cargo.toml b/Cargo.toml index fa180c0..3d3f9d6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,11 +4,6 @@ version = "0.1.0" edition = "2018" authors = ["Tobias Reisinger "] -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -#[profile.release] -#panic = 'abort' - [dependencies] actix-web = "4.4" diff --git a/src/db.rs b/src/db/mod.rs similarity index 100% rename from src/db.rs rename to src/db/mod.rs diff --git a/src/handlers/errors.rs b/src/handlers/errors.rs index 6cc8cf1..ab783e1 100644 --- a/src/handlers/errors.rs +++ b/src/handlers/errors.rs @@ -10,6 +10,7 @@ pub enum ApiError { BadUid, ProtectedSchedule, DatabaseError(DatabaseError), + InternalError(String), } impl ApiError { @@ -18,6 +19,7 @@ impl ApiError { ApiError::BadUid => StatusCode::BAD_REQUEST, ApiError::ProtectedSchedule => StatusCode::FORBIDDEN, ApiError::DatabaseError(db_error) => db_error.get_code(), + ApiError::InternalError(_) => StatusCode::INTERNAL_SERVER_ERROR, } } } @@ -40,6 +42,7 @@ impl From<&ApiError> for String { ApiError::BadUid => String::from("the uid is in a bad format"), ApiError::ProtectedSchedule => String::from("the targeted schedule is protected"), ApiError::DatabaseError(db_err) => String::from(db_err), + ApiError::InternalError(msg) => msg.clone(), } } } diff --git a/src/main.rs b/src/main.rs index 03eeb33..6f8ef7b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,3 @@ -extern crate dotenv; - use std::str::FromStr; use actix_web::middleware::TrailingSlash;