Skip to content

Commit

Permalink
Fix deprecation warnings in assets handler (#1031)
Browse files Browse the repository at this point in the history
  • Loading branch information
divergentdave committed May 6, 2024
1 parent 79052a7 commit 1912c08
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/handler/assets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,25 +32,25 @@ impl Handler for ReactApp {
if conn.path().starts_with("/api_url") {
return conn
.ok(self.api_url.to_string())
.with_header(KnownHeaderName::ContentType, "text/plain")
.with_header(CacheControl, NoCache);
.with_response_header(KnownHeaderName::ContentType, "text/plain")
.with_response_header(CacheControl, NoCache);
}

conn = self.handler.run(conn).await;

if conn.is_halted() {
if conn.path().starts_with("/assets" /*hashed assets*/) {
conn.with_header(CacheControl, MaxAge(ONE_YEAR))
conn.with_response_header(CacheControl, MaxAge(ONE_YEAR))
} else {
conn.with_header(CacheControl, NoCache)
conn.with_response_header(CacheControl, NoCache)
}
} else {
conn.push_path("/index.html".into());
conn = self
.handler
.run(conn)
.await
.with_header(CacheControl, NoCache)
.with_response_header(CacheControl, NoCache)
.with_status(Status::Ok);
conn.pop_path();
conn
Expand Down

0 comments on commit 1912c08

Please sign in to comment.