diff --git a/src/main.rs b/src/main.rs index 1dbc62f..adc0331 100644 --- a/src/main.rs +++ b/src/main.rs @@ -17,13 +17,14 @@ mod template; #[tokio::main] async fn main() { - // Parse dotenv files and expose them as environment variables + // Development-only: Parse dotenv files and expose them as environment variables + #[cfg(debug_assertions)] dotenv().ok(); - // envy uses our Configuration struct to parse environment variables - let config = envy::from_env::().expect("Please provide PORT env var"); + // Envy uses our Configuration struct to parse environment variables + let config = envy::from_env::().expect("Failed to parse environment variables"); - // initialize tracing + // Initialize tracing tracing_subscriber::fmt() // With the log_level from our config .with_max_level(config.log_level()) diff --git a/src/routes.rs b/src/routes.rs index fea5bd5..e6af75d 100644 --- a/src/routes.rs +++ b/src/routes.rs @@ -1,13 +1,10 @@ use crate::error::{get_error_response, TimeBannerError}; -use axum::body::{Body, Bytes}; +use axum::body::Bytes; use axum::extract::Path; -use axum::http::header; -use axum::response::{Redirect, Response}; -use axum::{http::StatusCode, response::IntoResponse}; -use chrono::{DateTime, NaiveDateTime, Offset, Utc}; +use axum::response::{IntoResponse, Redirect}; +use chrono::{DateTime, Utc}; use crate::raster::Rasterizer; -use crate::template::{render_template, OutputForm, RenderContext}; pub fn split_on_extension(path: &str) -> Option<(&str, &str)> { let split = path.rsplit_once('.')?; @@ -21,7 +18,7 @@ pub fn split_on_extension(path: &str) -> Option<(&str, &str)> { } fn parse_path(path: &str) -> (&str, &str) { - split_on_extension(path).or(Some((path, "svg"))).unwrap() + split_on_extension(path).unwrap_or((path, "svg")) } fn handle_rasterize(data: String, extension: &str) -> Result<(&str, Bytes), TimeBannerError> {