From b314f300fcd951ef33612e9a0f860710d5967563 Mon Sep 17 00:00:00 2001
From: Brandon Clayton <bclayton@usgs.gov>
Date: Fri, 25 Jun 2021 10:36:28 -0600
Subject: [PATCH] update context path for swagger

---
 .../nshmp/netcdf/www/ContextPathCookie.java   | 39 -------------------
 src/main/resources/swagger/index.js           | 13 +------
 2 files changed, 1 insertion(+), 51 deletions(-)
 delete mode 100644 src/main/java/gov/usgs/earthquake/nshmp/netcdf/www/ContextPathCookie.java

diff --git a/src/main/java/gov/usgs/earthquake/nshmp/netcdf/www/ContextPathCookie.java b/src/main/java/gov/usgs/earthquake/nshmp/netcdf/www/ContextPathCookie.java
deleted file mode 100644
index d8a8789..0000000
--- a/src/main/java/gov/usgs/earthquake/nshmp/netcdf/www/ContextPathCookie.java
+++ /dev/null
@@ -1,39 +0,0 @@
-package gov.usgs.earthquake.nshmp.netcdf.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));
-  }
-
-}
diff --git a/src/main/resources/swagger/index.js b/src/main/resources/swagger/index.js
index f9288b5..1f6f9fb 100644
--- a/src/main/resources/swagger/index.js
+++ b/src/main/resources/swagger/index.js
@@ -1,17 +1,6 @@
 window.onload = function() {
-  const extract = function(v) {
-    return decodeURIComponent(
-        v.replace(
-          /(?:(?:^|.*;\s*)contextPath\s*\=\s*([^;]*).*$)|^.*$/,
-          '$1'
-        )
-      );
-  };
-
-  const contextPath = extract(document.cookie);
-
   const ui = SwaggerUIBundle({
-    url: `${contextPath}/swagger`,
+    url: `./swagger`,
     dom_id: '#swagger-ui',
     tagsSorter: 'alpha',
     presets: [SwaggerUIBundle.presets.apis, SwaggerUIStandalonePreset],
-- 
GitLab