Skip to content

Commit

Permalink
refactor: use new axum middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
vidhanio committed Nov 27, 2023
1 parent 946d526 commit 0f4a095
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/static.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{ffi::OsStr, path::PathBuf, time::Duration};
use std::{ffi::OsStr, future, path::PathBuf, time::Duration};

use axum::{extract::Path, Router};
use axum_extra::{
Expand All @@ -7,7 +7,6 @@ use axum_extra::{
TypedHeader,
};
use include_dir::{include_dir, Dir};
use tower::ServiceBuilder;
use tracing::instrument;

use crate::{App, Error};
Expand All @@ -18,12 +17,12 @@ pub fn router() -> Router<App> {
.route("/LICENSE.txt", axum::routing::get(license))
.route("/styles.css", axum::routing::get(styles))
.route("/fonts/:font", axum::routing::get(fonts))
.layer(ServiceBuilder::new().map_response(|res| {
.layer(axum::middleware::map_response(|res| {
let cc = CacheControl::new()
.with_max_age(Duration::from_secs(60 * 60 * 24 * 365))
.with_immutable();

(TypedHeader(cc), res)
future::ready((TypedHeader(cc), res))
}))
}

Expand Down

0 comments on commit 0f4a095

Please sign in to comment.