Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
httpd: Only return cache header on success
Sebastian Martinez committed 2 years ago
commit 3aca2a11b0178854fe8788eb42b4c2265a0423a1
parent 04a4aa06c919b3666e48623768e5580228bbb898
1 file changed +7 -2
modified radicle-httpd/src/api/v1/projects.rs
@@ -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;
@@ -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))
+
                    },
                )),
            ),
        )