From 1ba74c8b0459616d376d4787066e0d00d16f3349 Mon Sep 17 00:00:00 2001 From: Brandon Clayton <bclayton@usgs.gov> Date: Wed, 30 Jun 2021 10:52:50 -0600 Subject: [PATCH] remove context cookie --- .../nshmp/www/ContextPathCookie.java | 39 ------------------- 1 file changed, 39 deletions(-) delete mode 100644 src/main/java/gov/usgs/earthquake/nshmp/www/ContextPathCookie.java diff --git a/src/main/java/gov/usgs/earthquake/nshmp/www/ContextPathCookie.java b/src/main/java/gov/usgs/earthquake/nshmp/www/ContextPathCookie.java deleted file mode 100644 index dcdf890cb..000000000 --- a/src/main/java/gov/usgs/earthquake/nshmp/www/ContextPathCookie.java +++ /dev/null @@ -1,39 +0,0 @@ -package gov.usgs.earthquake.nshmp.www; - -import java.time.Duration; - -import org.reactivestreams.Publisher; - -import io.micronaut.context.annotation.Requires; -import io.micronaut.context.annotation.Value; -import io.micronaut.core.async.publisher.Publishers; -import io.micronaut.http.HttpMethod; -import io.micronaut.http.HttpRequest; -import io.micronaut.http.MutableHttpResponse; -import io.micronaut.http.annotation.Filter; -import io.micronaut.http.cookie.Cookie; -import io.micronaut.http.filter.HttpServerFilter; -import io.micronaut.http.filter.ServerFilterChain; - -/** - * Add context path as a cookie for Swagger to use. - * - * @author U.S. Geological Survey - */ -@Requires(property = "micronaut.server.context-path") -@Filter(methods = { HttpMethod.GET, HttpMethod.HEAD }, - patterns = { "/**" }) -public class ContextPathCookie implements HttpServerFilter { - private final Cookie contextPathCookie; - - ContextPathCookie(@Value("${micronaut.server.context-path}") String contextPath) { - this.contextPathCookie = Cookie.of("contextPath", contextPath).maxAge(Duration.ofMinutes(2L)); - } - - @Override - public Publisher<MutableHttpResponse<?>> doFilter(HttpRequest<?> request, - ServerFilterChain chain) { - return Publishers.map(chain.proceed(request), response -> response.cookie(contextPathCookie)); - } - -} -- GitLab