Skip to content

Commit 1c5779c

Browse files
authored
Merge pull request #7 from Foundation-Devices/renovate/axum-0.x
fix(deps): update rust crate axum to 0.6.20
2 parents fe85c03 + 25d969d commit 1c5779c

3 files changed

Lines changed: 7 additions & 7 deletions

File tree

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ name = "demo"
2020
name = "echo"
2121

2222
[dependencies]
23-
axum = { version = "0.6.0-rc.1", features = ["json"] }
23+
axum = { version = "0.6.20", features = ["json"] }
2424
clap = { version = "4", features = ["derive", "env"] }
2525
once_cell = "1.18"
2626
prometheus = "0.13"

examples/demo/main.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// SPDX-License-Identifier: AGPL-3.0-or-later
44

55
use servus::axum::{
6-
extract::{self, Extension},
6+
extract::{self, State},
77
http::StatusCode,
88
response::IntoResponse,
99
routing::{get, post},
@@ -76,7 +76,7 @@ struct Message {
7676
}
7777

7878
async fn post_message(
79-
Extension(state): Extension<Arc<AppState>>,
79+
State(state): State<Arc<AppState>>,
8080
extract::Json(payload): extract::Json<Message>,
8181
) -> StatusCode {
8282
info!(
@@ -100,7 +100,7 @@ async fn post_message(
100100
StatusCode::OK
101101
}
102102

103-
async fn get_messages(Extension(state): Extension<Arc<AppState>>) -> impl IntoResponse {
103+
async fn get_messages(State(state): State<Arc<AppState>>) -> impl IntoResponse {
104104
info!(message = "got get messages request!");
105105

106106
let q = sqlx::query!("select * from guestbook")

src/http/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
99
pub mod metrics;
1010

11-
use axum::{extract::Extension, http::StatusCode, middleware, routing, Router, Server};
11+
use axum::{http::StatusCode, middleware, routing, Router, Server};
1212
use std::net::SocketAddr;
1313
use tower_http::trace::{DefaultMakeSpan, TraceLayer};
1414
use tracing::{error, Level};
@@ -35,15 +35,15 @@ use tracing::{error, Level};
3535
pub async fn serve<S>(
3636
http_address: SocketAddr,
3737
metrics_address: Option<SocketAddr>,
38-
router: Router,
38+
router: Router<S>,
3939
state: S,
4040
) where
4141
S: Send + Sync + Clone + 'static,
4242
{
4343
// create primary application router and server
4444
// applying handler state if we have it, and default metrics/tracing middleware
4545
let r = router
46-
.layer(Extension(state))
46+
.with_state(state)
4747
.route_layer(middleware::from_fn(metrics::middleware)) // only record matched routes
4848
.layer(
4949
TraceLayer::new_for_http().make_span_with(

0 commit comments

Comments
 (0)