response = restTemplate.getForEntity(uri, String.class);
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK);
diff --git a/src/gwc/autoconfigure/src/main/java/org/geoserver/cloud/autoconfigure/web/gwc/GeoWebCacheUIAutoConfiguration.java b/src/gwc/autoconfigure/src/main/java/org/geoserver/cloud/autoconfigure/web/gwc/GeoWebCacheUIAutoConfiguration.java
index 39f5aee81..e266181dd 100644
--- a/src/gwc/autoconfigure/src/main/java/org/geoserver/cloud/autoconfigure/web/gwc/GeoWebCacheUIAutoConfiguration.java
+++ b/src/gwc/autoconfigure/src/main/java/org/geoserver/cloud/autoconfigure/web/gwc/GeoWebCacheUIAutoConfiguration.java
@@ -6,15 +6,18 @@
import lombok.extern.slf4j.Slf4j;
-import org.geoserver.cloud.autoconfigure.gwc.ConditionalOnGeoWebCacheRestConfigEnabled;
+import org.geoserver.catalog.Catalog;
import org.geoserver.cloud.autoconfigure.gwc.ConditionalOnWebUIEnabled;
import org.geoserver.cloud.gwc.config.core.GeoWebCacheConfigurationProperties;
+import org.geoserver.gwc.controller.GwcUrlHandlerMapping;
import org.geowebcache.GeoWebCacheDispatcher;
import org.geowebcache.rest.controller.ByteStreamController;
import org.gwc.web.rest.GeoWebCacheController;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
+import org.springframework.boot.autoconfigure.web.servlet.WebMvcRegistrations;
import org.springframework.context.annotation.Bean;
+import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;
import javax.annotation.PostConstruct;
@@ -32,13 +35,51 @@ GeoWebCacheController gwcController(GeoWebCacheDispatcher gwcDispatcher) {
return new GeoWebCacheController(gwcDispatcher);
}
- /**
- * Provide a handler for static web resources if missing, for example, because {@link
- * ConditionalOnGeoWebCacheRestConfigEnabled} is disabled
- */
+ /** ConditionalOnGeoWebCacheRestConfigEnabled} is disabled */
@Bean
@ConditionalOnMissingBean(ByteStreamController.class)
ByteStreamController byteStreamController() {
return new ByteStreamController();
}
+
+ /**
+ * GS's src/web/gwc/src/main/java/applicationContext.xml
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ */
+ @Bean
+ WebMvcRegistrations gwcDemoUrlHandlerMapping(Catalog catalog) {
+ GwcUrlHandlerMapping handler = new GwcUrlHandlerMapping(catalog, "/gwc/demo");
+ handler.setAlwaysUseFullPath(true);
+ handler.setOrder(10);
+
+ return new WebMvcRegistrations() {
+ @Override
+ public RequestMappingHandlerMapping getRequestMappingHandlerMapping() {
+ return handler;
+ }
+ };
+ }
+
+ @Bean
+ WebMvcRegistrations gwcRestWebUrlHandlerMapping(Catalog catalog) {
+ GwcUrlHandlerMapping handler = new GwcUrlHandlerMapping(catalog, "/gwc/rest/web");
+ handler.setAlwaysUseFullPath(true);
+ handler.setOrder(10);
+
+ return new WebMvcRegistrations() {
+ @Override
+ public RequestMappingHandlerMapping getRequestMappingHandlerMapping() {
+ return handler;
+ }
+ };
+ }
}
diff --git a/src/gwc/autoconfigure/src/test/java/org/geoserver/cloud/autoconfigure/gwc/web/gwc/GeoWebCacheUIAutoConfigurationTest.java b/src/gwc/autoconfigure/src/test/java/org/geoserver/cloud/autoconfigure/gwc/web/gwc/GeoWebCacheUIAutoConfigurationTest.java
new file mode 100644
index 000000000..273bc1f05
--- /dev/null
+++ b/src/gwc/autoconfigure/src/test/java/org/geoserver/cloud/autoconfigure/gwc/web/gwc/GeoWebCacheUIAutoConfigurationTest.java
@@ -0,0 +1,38 @@
+package org.geoserver.cloud.autoconfigure.gwc.web.gwc;
+
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+import org.geoserver.cloud.autoconfigure.gwc.GeoWebCacheContextRunner;
+import org.geoserver.cloud.autoconfigure.web.gwc.GeoWebCacheUIAutoConfiguration;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
+import org.springframework.boot.autoconfigure.AutoConfigurations;
+import org.springframework.boot.test.context.runner.WebApplicationContextRunner;
+
+import java.io.File;
+
+public class GeoWebCacheUIAutoConfigurationTest {
+
+ WebApplicationContextRunner runner;
+
+ @TempDir File tmpDir;
+
+ @BeforeEach
+ void setUp() throws Exception {
+ runner =
+ GeoWebCacheContextRunner.newMinimalGeoWebCacheContextRunner(tmpDir)
+ .withPropertyValues("gwc.web-ui=true")
+ .withConfiguration(
+ AutoConfigurations.of(GeoWebCacheUIAutoConfiguration.class));
+ }
+
+ @Test
+ void beansForLocalWorkspacePathsHandlingArePresent() {
+ runner.run(
+ context -> {
+ assertNotNull(context.getBean("gwcDemoUrlHandlerMapping"));
+ assertNotNull(context.getBean("gwcRestWebUrlHandlerMapping"));
+ });
+ }
+}
diff --git a/src/gwc/services/src/main/java/org/gwc/web/rest/GeoWebCacheController.java b/src/gwc/services/src/main/java/org/gwc/web/rest/GeoWebCacheController.java
index 021920b80..5b8cc0400 100644
--- a/src/gwc/services/src/main/java/org/gwc/web/rest/GeoWebCacheController.java
+++ b/src/gwc/services/src/main/java/org/gwc/web/rest/GeoWebCacheController.java
@@ -25,19 +25,13 @@
* Copied from {@link GeoServerGWCDispatcherController}
*/
@Controller
-@RequestMapping("/gwc")
+@RequestMapping(path = {"/gwc", "/{namespace}/gwc"})
@RequiredArgsConstructor
public class GeoWebCacheController {
private final @NonNull GeoWebCacheDispatcher gwcDispatcher;
- @GetMapping(
- path = {
- "",
- "/home",
- "/demo/**",
- "/proxy/**",
- })
+ @GetMapping(path = {"", "/home", "/demo/**", "/proxy/**"})
public void handleGet(HttpServletRequest request, HttpServletResponse response)
throws Exception {
gwcDispatcher.handleRequest(request, response);