diff options
author | Santo Cariotti <santo@dcariotti.me> | 2022-08-23 18:57:16 +0200 |
---|---|---|
committer | Santo Cariotti <santo@dcariotti.me> | 2022-08-23 18:57:16 +0200 |
commit | 2231ab6730552d3b58b00ae42d490743a29d7c8b (patch) | |
tree | 4a9612ec08398b8abc2e4ce7c30825f7ef18659c /server/src/main.rs | |
parent | bba5f252f265e6102d2f052e9ca100efe318508f (diff) |
Add docs
Diffstat (limited to 'server/src/main.rs')
-rw-r--r-- | server/src/main.rs | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/server/src/main.rs b/server/src/main.rs index 8e44f7a..508d6cd 100644 --- a/server/src/main.rs +++ b/server/src/main.rs @@ -13,10 +13,12 @@ use tower_http::sensitive_headers::SetSensitiveHeadersLayer; use tower_http::{classify::ServerErrorsFailureClass, trace::TraceLayer}; use tracing::Span; +/// Main application, called by the execution of the software #[tokio::main] async fn main() { let app = create_app().await; + /// By default the server is bind at "127.0.0.1:3000" let addr = std::env::var("ALLOWED_HOST").unwrap_or_else(|_| "127.0.0.1:3000".to_string()); tracing::info!("Listening on {}", addr); @@ -26,6 +28,7 @@ async fn main() { .unwrap(); } +/// Create the app: setup everything and returns a `Router` async fn create_app() -> Router { logger::setup(); let _ = db::setup().await; @@ -35,12 +38,14 @@ async fn create_app() -> Router { .nest("/auth", routes::auth::create_route()); Router::new() + // Map all routes to `/v1/*` namespace .nest("/v1", api_routes) // Mark the `Authorization` request header as sensitive so it doesn't // show in logs. .layer(SetSensitiveHeadersLayer::new(std::iter::once( header::AUTHORIZATION, ))) + // Use a layer for `TraceLayer` .layer( TraceLayer::new_for_http() .on_request(|request: &Request<_>, _span: &Span| { |