Skip to content

Commit

Permalink
Update axum 0.6.1 to 0.7.1
Browse files Browse the repository at this point in the history
  • Loading branch information
bouzuya committed Dec 2, 2023
1 parent 3dafdfd commit 3c227e5
Show file tree
Hide file tree
Showing 3 changed files with 124 additions and 69 deletions.
179 changes: 117 additions & 62 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Expand Up @@ -6,8 +6,8 @@ edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
anyhow = "1.0.68"
axum = "0.6.1"
anyhow = "1.0.75"
axum = "0.7.1"
clap = { version = "4.0.32", features = ["derive"] }
clap_complete = "4.0.7"
thiserror = "1.0.38"
Expand Down
10 changes: 5 additions & 5 deletions src/command.rs
Expand Up @@ -3,9 +3,10 @@ use axum::{
http::{header::LOCATION, HeaderMap, HeaderValue, StatusCode},
response::IntoResponse,
routing::get,
Router, Server,
Router,
};
use std::{collections::HashMap, sync::Arc};
use tokio::net::TcpListener;
use uuid::Uuid;

use crate::count::Count;
Expand Down Expand Up @@ -57,7 +58,7 @@ pub async fn server() -> anyhow::Result<()> {
let base_path = std::env::var("BASE_PATH").unwrap_or_else(|_| "".to_string());
let port = std::env::var("PORT").unwrap_or_else(|_| "8080".to_string());
let host = "0.0.0.0";
let addr = format!("{}:{}", host, port).parse()?;
let addr = format!("{}:{}", host, port);

let state = State {
base_path: base_path.clone(),
Expand All @@ -74,9 +75,8 @@ pub async fn server() -> anyhow::Result<()> {
}
.layer(Extension(Arc::new(state)));

Ok(Server::bind(&addr)
.serve(wrapped_router.into_make_service())
.await?)
let listener = TcpListener::bind(&addr).await?;
Ok(axum::serve(listener, wrapped_router.into_make_service()).await?)
}
#[cfg(test)]
mod tests {
Expand Down

0 comments on commit 3c227e5

Please sign in to comment.