Skip to content

Commit

Permalink
feat: Updates for axum 0.7 and markup.rs 0.15
Browse files Browse the repository at this point in the history
  • Loading branch information
johnbcodes committed Nov 27, 2023
1 parent f590cee commit 05f6922
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
6 changes: 3 additions & 3 deletions src/assets.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use axum::{
body::{boxed, Full},
body::Body,
http::{header, StatusCode, Uri},
response::{IntoResponse, Response},
};
Expand Down Expand Up @@ -27,7 +27,7 @@ where
match Assets::get(path.as_str()) {
Some(content) => {
info!("Retrieving asset with path: {path}");
let body = boxed(Full::from(content.data));
let body = Body::from(content.data);
let mime = mime_guess::from_path(path).first_or_octet_stream();
Response::builder()
.header(header::CONTENT_TYPE, mime.as_ref())
Expand All @@ -37,7 +37,7 @@ where
}
None => Response::builder()
.status(StatusCode::NOT_FOUND)
.body(boxed(Full::from("Not Found")))
.body(Body::from("Not Found"))
.unwrap(),
}
}
Expand Down
13 changes: 6 additions & 7 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#![warn(clippy::all)]
#![deny(unreachable_pub, private_in_public)]
#![deny(unreachable_pub, private_bounds, private_interfaces)]
#![forbid(unsafe_code)]

mod assets;
mod currency;
mod error;
mod layout;
pub mod layout;
pub mod line_item_dates;
pub mod line_items;
pub mod quotes;
Expand All @@ -24,6 +24,7 @@ use diesel::r2d2::{ConnectionManager, Pool};
use diesel_migrations::{embed_migrations, EmbeddedMigrations, MigrationHarness};
use dotenvy::dotenv;
use std::env;
use tokio::net::TcpListener;
use tower_http::trace::{DefaultOnResponse, TraceLayer};
use tower_http::LatencyUnit;
use tracing::{info, Level};
Expand Down Expand Up @@ -120,10 +121,8 @@ async fn main() {
.layer(trace_layer)
.fallback_service(asset_handler.into_service());

let addr = "[::]:8080".parse().unwrap();
let addr: std::net::SocketAddr = "[::]:8080".parse().unwrap();
info!("listening on {addr}");
axum::Server::bind(&addr)
.serve(app.into_make_service())
.await
.unwrap();
let listener = TcpListener::bind(addr).await.unwrap();
axum::serve(listener, app).await.unwrap();
}

0 comments on commit 05f6922

Please sign in to comment.