Skip to content

Commit

Permalink
fix: use State extractor
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucky3028 committed Jan 18, 2023
1 parent d594f8c commit 4dc325a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ mod infra_axum_handlers {
use crate::domain::PlayerDataRepository;
use crate::use_cases::GetAllPlayerDataUseCase;
use axum::body;
use axum::extract::State;
use axum::handler::Handler;
use axum::http::StatusCode;
use axum::response::{IntoResponse, Response};
Expand Down Expand Up @@ -199,7 +200,7 @@ mod infra_axum_handlers {
)
}

pub fn handle_get_metrics(state: SharedAppState) -> impl Handler<()> {
pub fn handle_get_metrics(State(state): State<SharedAppState>) -> impl Handler<()> {
// we need a separate handler function to create an error tracing span
#[tracing::instrument]
async fn handler(state: &SharedAppState) -> Response {
Expand Down Expand Up @@ -437,7 +438,8 @@ mod app {
use axum::Router;

Router::new()
.route("/metrics", get(handle_get_metrics(shared_state.clone())))
.route("/metrics", get(handle_get_metrics))
.with_state(shared_state.clone())
.layer(TraceLayer::new_for_http())
};

Expand Down

0 comments on commit 4dc325a

Please sign in to comment.