#581 Skip trailing slash (#586)

This commit is contained in:
German Osin 2021-06-25 15:39:07 +03:00 committed by GitHub
parent 80581f6288
commit 1a916ab247
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 3 deletions

View file

@ -12,6 +12,7 @@ services:
- kafka - kafka
environment: environment:
KAFKA_CLUSTERS_0_NAME: local KAFKA_CLUSTERS_0_NAME: local
# SERVER_SERVLET_CONTEXT_PATH: "/kafkaui"
KAFKA_CLUSTERS_0_BOOTSTRAPSERVERS: kafka:9092 KAFKA_CLUSTERS_0_BOOTSTRAPSERVERS: kafka:9092
KAFKA_CLUSTERS_0_ZOOKEEPER: zookeeper:2181 KAFKA_CLUSTERS_0_ZOOKEEPER: zookeeper:2181
KAFKA_CLUSTERS_0_PROPERTIES_SECURITY_PROTOCOL: SASL_PLAINTEXT KAFKA_CLUSTERS_0_PROPERTIES_SECURITY_PROTOCOL: SASL_PLAINTEXT

View file

@ -1,5 +1,6 @@
package com.provectus.kafka.ui.config; package com.provectus.kafka.ui.config;
import java.util.Optional;
import org.springframework.boot.autoconfigure.web.ServerProperties; import org.springframework.boot.autoconfigure.web.ServerProperties;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.web.server.ServerWebExchange; import org.springframework.web.server.ServerWebExchange;
@ -22,13 +23,13 @@ public class CustomWebFilter implements WebFilter {
String contextPath = serverProperties.getServlet().getContextPath() != null String contextPath = serverProperties.getServlet().getContextPath() != null
? serverProperties.getServlet().getContextPath() : ""; ? serverProperties.getServlet().getContextPath() : "";
if (exchange.getRequest().getURI().getPath().equals(contextPath + "/") final String path = exchange.getRequest().getURI().getPath().replaceAll("/$", "");
|| exchange.getRequest().getURI().getPath().startsWith(contextPath + "/ui")) { if (path.equals(contextPath) || path.startsWith(contextPath + "/ui")) {
return chain.filter( return chain.filter(
exchange.mutate().request(exchange.getRequest().mutate().path("/index.html").build()) exchange.mutate().request(exchange.getRequest().mutate().path("/index.html").build())
.build() .build()
); );
} else if (exchange.getRequest().getURI().getPath().startsWith(contextPath)) { } else if (path.startsWith(contextPath)) {
return chain.filter( return chain.filter(
exchange.mutate().request(exchange.getRequest().mutate().contextPath(contextPath).build()) exchange.mutate().request(exchange.getRequest().mutate().contextPath(contextPath).build())
.build() .build()