-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove rustfmt.toml and use defaults (#436)
* Remove rustfmt.toml and use defaults * Use allow(dead_code) with not used variables
- Loading branch information
Showing
25 changed files
with
942 additions
and
945 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,48 @@ | ||
use axum::http::header; | ||
use axum::Router; | ||
use tower_http::{ | ||
compression::CompressionLayer, cors::CorsLayer, propagate_header::PropagateHeaderLayer, | ||
sensitive_headers::SetSensitiveHeadersLayer, trace, | ||
compression::CompressionLayer, cors::CorsLayer, propagate_header::PropagateHeaderLayer, | ||
sensitive_headers::SetSensitiveHeadersLayer, trace, | ||
}; | ||
|
||
use crate::logger; | ||
use crate::models; | ||
use crate::routes; | ||
|
||
pub async fn create_app() -> Router { | ||
logger::setup(); | ||
logger::setup(); | ||
|
||
models::sync_indexes() | ||
.await | ||
.expect("Failed to sync database indexes"); | ||
models::sync_indexes() | ||
.await | ||
.expect("Failed to sync database indexes"); | ||
|
||
Router::new() | ||
.merge(routes::status::create_route()) | ||
.merge(routes::user::create_route()) | ||
.merge(Router::new().nest( | ||
"/v1", | ||
// All public v1 routes will be nested here. | ||
Router::new().merge(routes::cat::create_route()), | ||
)) | ||
// High level logging of requests and responses | ||
.layer( | ||
trace::TraceLayer::new_for_http() | ||
.make_span_with(trace::DefaultMakeSpan::new().include_headers(true)) | ||
.on_request(trace::DefaultOnRequest::new().level(tracing::Level::INFO)) | ||
.on_response(trace::DefaultOnResponse::new().level(tracing::Level::INFO)), | ||
) | ||
// Mark the `Authorization` request header as sensitive so it doesn't | ||
// show in logs. | ||
.layer(SetSensitiveHeadersLayer::new(std::iter::once( | ||
header::AUTHORIZATION, | ||
))) | ||
// Compress responses | ||
.layer(CompressionLayer::new()) | ||
// Propagate `X-Request-Id`s from requests to responses | ||
.layer(PropagateHeaderLayer::new(header::HeaderName::from_static( | ||
"x-request-id", | ||
))) | ||
// CORS configuration. This should probably be more restrictive in | ||
// production. | ||
.layer(CorsLayer::permissive()) | ||
Router::new() | ||
.merge(routes::status::create_route()) | ||
.merge(routes::user::create_route()) | ||
.merge(Router::new().nest( | ||
"/v1", | ||
// All public v1 routes will be nested here. | ||
Router::new().merge(routes::cat::create_route()), | ||
)) | ||
// High level logging of requests and responses | ||
.layer( | ||
trace::TraceLayer::new_for_http() | ||
.make_span_with(trace::DefaultMakeSpan::new().include_headers(true)) | ||
.on_request(trace::DefaultOnRequest::new().level(tracing::Level::INFO)) | ||
.on_response(trace::DefaultOnResponse::new().level(tracing::Level::INFO)), | ||
) | ||
// Mark the `Authorization` request header as sensitive so it doesn't | ||
// show in logs. | ||
.layer(SetSensitiveHeadersLayer::new(std::iter::once( | ||
header::AUTHORIZATION, | ||
))) | ||
// Compress responses | ||
.layer(CompressionLayer::new()) | ||
// Propagate `X-Request-Id`s from requests to responses | ||
.layer(PropagateHeaderLayer::new(header::HeaderName::from_static( | ||
"x-request-id", | ||
))) | ||
// CORS configuration. This should probably be more restrictive in | ||
// production. | ||
.layer(CorsLayer::permissive()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.