From 2606372a142c65d9bb29eb5b80dbaeeaa9354933 Mon Sep 17 00:00:00 2001 From: xphoniex Date: Thu, 16 Feb 2023 15:51:31 +0000 Subject: [PATCH] httpd: Use `State` instead of `Extension` for `root_handler` Signed-off-by: xphoniex --- radicle-httpd/src/api.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/radicle-httpd/src/api.rs b/radicle-httpd/src/api.rs index 462624a5..4f89da50 100644 --- a/radicle-httpd/src/api.rs +++ b/radicle-httpd/src/api.rs @@ -4,11 +4,12 @@ use std::collections::HashMap; use std::sync::Arc; use std::time::Duration; +use axum::extract::State; use axum::http::header::{AUTHORIZATION, CONTENT_TYPE}; use axum::http::Method; use axum::response::{IntoResponse, Json}; use axum::routing::get; -use axum::{Extension, Router}; +use axum::Router; use serde::{Deserialize, Serialize}; use serde_json::json; use tokio::sync::RwLock; @@ -78,7 +79,7 @@ impl Context { pub fn router(ctx: Context) -> Router { let root_router = Router::new() .route("/", get(root_handler)) - .layer(Extension(ctx.clone())); + .with_state(ctx.clone()); Router::new() .merge(root_router) @@ -98,7 +99,7 @@ pub fn router(ctx: Context) -> Router { ) } -async fn root_handler(Extension(ctx): Extension) -> impl IntoResponse { +async fn root_handler(State(ctx): State) -> impl IntoResponse { let response = json!({ "message": "Welcome!", "service": "radicle-httpd",