Ver código fonte

PLTF-1110: explicit static path

Arkadii Chumachenko 1 ano atrás
pai
commit
48ffb76a4d

+ 8 - 1
kafka-ui-api/src/main/java/com/provectus/kafka/ui/controller/StaticController.java

@@ -23,6 +23,9 @@ public class StaticController {
   @Value("classpath:static/manifest.json")
   private Resource manifestFile;
 
+  @Value("#{environment.STATIC_PATH}")
+  private String staticPath;
+
   private final AtomicReference<String> renderedIndexFile = new AtomicReference<>();
   private final AtomicReference<String> renderedManifestFile = new AtomicReference<>();
 
@@ -39,7 +42,11 @@ public class StaticController {
   public String getRenderedFile(ServerWebExchange exchange, AtomicReference<String> renderedFile, Resource file) {
     String rendered = renderedFile.get();
     if (rendered == null) {
-      rendered = buildFile(file, exchange.getRequest().getPath().contextPath().value());
+      String contextPath = staticPath;
+      if (contextPath == null) {
+          contextPath = exchange.getRequest().getPath().contextPath().value();
+      }
+      rendered = buildFile(file, contextPath);
       if (renderedFile.compareAndSet(null, rendered)) {
         return rendered;
       } else {