Skip to content
This repository has been archived by the owner on Apr 29, 2024. It is now read-only.

Commit

Permalink
httpd: Only return cache header on success
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastinez authored and cloudhead committed Mar 21, 2024
1 parent 04a4aa0 commit 3aca2a1
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions radicle-httpd/src/api/v1/projects.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::collections::{BTreeMap, HashMap};
use axum::extract::{DefaultBodyLimit, State};
use axum::handler::Handler;
use axum::http::{header, HeaderValue};
use axum::response::IntoResponse;
use axum::response::{IntoResponse, Response};
use axum::routing::{get, patch, post};
use axum::{Json, Router};
use axum_auth::AuthBearer;
Expand Down Expand Up @@ -43,7 +43,12 @@ pub fn router(ctx: Context) -> Router {
get(
activity_handler.layer(SetResponseHeaderLayer::if_not_present(
header::CACHE_CONTROL,
HeaderValue::from_static(CACHE_1_HOUR),
|response: &Response| {
response
.status()
.is_success()
.then_some(HeaderValue::from_static(CACHE_1_HOUR))
},
)),
),
)
Expand Down

0 comments on commit 3aca2a1

Please sign in to comment.