diff options
Diffstat (limited to 'src/lib.rs')
-rw-r--r-- | src/lib.rs | 36 |
1 files changed, 1 insertions, 35 deletions
@@ -1,4 +1,3 @@ -use axum::{http::Uri, response::IntoResponse}; use tower_http::{cors::CorsLayer, trace::TraceLayer}; pub use error::{Error, Result}; @@ -12,32 +11,16 @@ pub mod utils; pub fn router() -> axum::Router<state::AppState> { axum::Router::new() .nest("/api", api::router()) - .merge(auth::router()) - .fallback(fallback) + .nest("/auth", auth::router()) // TODO: do this correctly! .layer(CorsLayer::permissive()) .layer(TraceLayer::new_for_http()) } -pub async fn fallback(uri: Uri) -> impl IntoResponse { - Error::RouteNotFound(uri) -} - #[cfg(test)] pub(crate) mod tests { - use crate::state::AppState; - - use super::*; - use std::sync::Once; - use axum::{ - body::Body, - http::{Request, StatusCode}, - Router, - }; - use sqlx::PgPool; - use tower::ServiceExt; use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt}; pub type TestResult<T = (), E = Box<dyn std::error::Error>> = std::result::Result<T, E>; @@ -56,21 +39,4 @@ pub(crate) mod tests { std::env::set_var("JWT_SECRET", JWT_SECRET); }); } - - #[sqlx::test] - async fn test_fallback_not_found(pool: PgPool) -> TestResult { - setup_test_env(); - - let router = Router::new().merge(router()).with_state(AppState { pool }); - - let request = Request::builder() - .uri("/does-not-exist") - .body(Body::empty())?; - - let response = router.oneshot(request).await?; - - assert_eq!(StatusCode::NOT_FOUND, response.status()); - - Ok(()) - } } |