From a37254452bece34e639f8eaf6904bb29de965a45 Mon Sep 17 00:00:00 2001 From: Hubert Van De Walle Date: Wed, 28 Oct 2020 02:58:30 +0100 Subject: [PATCH] Fix webmanifest --- .../kotlin/be/simplenotes/app/filters/ImmutableFilter.kt | 6 +++++- .../src/main/kotlin/be/simplenotes/app/routes/Router.kt | 8 +++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/simplenotes-app/src/main/kotlin/be/simplenotes/app/filters/ImmutableFilter.kt b/simplenotes-app/src/main/kotlin/be/simplenotes/app/filters/ImmutableFilter.kt index fd82ab5..495a5fd 100644 --- a/simplenotes-app/src/main/kotlin/be/simplenotes/app/filters/ImmutableFilter.kt +++ b/simplenotes-app/src/main/kotlin/be/simplenotes/app/filters/ImmutableFilter.kt @@ -3,9 +3,13 @@ package be.simplenotes.app.filters import org.http4k.core.Filter import org.http4k.core.HttpHandler import org.http4k.core.Request +import org.http4k.core.Status.Companion.OK object ImmutableFilter : Filter { override fun invoke(next: HttpHandler) = { request: Request -> - next(request).header("Cache-Control", "public, max-age=31536000, immutable") + val res = next(request) + if (res.status == OK) + res.header("Cache-Control", "public, max-age=31536000, immutable") + else res } } diff --git a/simplenotes-app/src/main/kotlin/be/simplenotes/app/routes/Router.kt b/simplenotes-app/src/main/kotlin/be/simplenotes/app/routes/Router.kt index d0862f4..70d3b6c 100644 --- a/simplenotes-app/src/main/kotlin/be/simplenotes/app/routes/Router.kt +++ b/simplenotes-app/src/main/kotlin/be/simplenotes/app/routes/Router.kt @@ -32,7 +32,13 @@ class Router( val basicRoutes = routes( "/health" bind GET to healthCheckController::healthCheck, - ImmutableFilter.then(static(Classpath("/static"), "woff2" to ContentType("font/woff2"))) + ImmutableFilter.then( + static( + Classpath("/static"), + "woff2" to ContentType("font/woff2"), + "webmanifest" to ContentType("application/manifest+json") + ) + ) ) val publicRoutes = routes(