Skip to content

Commit

Permalink
chore: update axum to 0.7
Browse files Browse the repository at this point in the history
  • Loading branch information
William-Karkegi committed Nov 28, 2023
1 parent 262a627 commit 870c971
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 37 deletions.
108 changes: 79 additions & 29 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ migration = { path = "migration" }
# Async
tokio = { version = "1", features = ["full"] }
# Web
axum = "0.6.20"
axum = "0.7.1"
# Json
serde = { version = "1", features = ["derive"] }
serde_json = "1.0"
Expand Down
12 changes: 5 additions & 7 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ use std::{env, net::SocketAddr};
use axum::{
middleware,
response::{IntoResponse, Response},
Json, Router, Server,
Json, Router,
};
use dotenv::dotenv;
use serde_json::json;
use tokio::net::TcpListener;
use tracing::{debug, info};

mod shared;
Expand All @@ -31,14 +32,11 @@ async fn main() -> Result<()> {
.layer(middleware::map_response(main_response_mapper))
.with_state(state);

let addr = SocketAddr::from(([0, 0, 0, 0], 8080));
let listener = TcpListener::bind("0.0.0.0:8080").await.unwrap();

info!("Listening on {addr}");
info!("Listening on: {}", listener.local_addr().unwrap());

Server::bind(&addr)
.serve(app.into_make_service())
.await
.unwrap();
axum::serve(listener, app).await.unwrap();

return Ok(());
}
Expand Down

0 comments on commit 870c971

Please sign in to comment.