Skip to content

Commit

Permalink
gwc - handles workspace-based paths (geoserver#380)
Browse files Browse the repository at this point in the history
  • Loading branch information
pmauduit committed Jan 29, 2024
1 parent f0a40a2 commit 986836b
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@

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;
Expand All @@ -32,13 +33,39 @@ 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
* <!-- Used for workspace-based demo requests so the requests to GS stay workspace-based -->
* <bean id="gwcDemoUrlHandlerMapping"
* class="org.geoserver.gwc.controller.GwcUrlHandlerMapping"> <constructor-arg ref="catalog" />
* <constructor-arg value="/gwc/demo"/> <property name="alwaysUseFullPath" value="true" />
* <property name="order" value="10" /> </bean>
* <!-- Used for workspace-based web requests (i.e. for rest/web/openlayer/ol.js) -->
* <bean id="gwcRestWebUrlHandlerMapping"
* class="org.geoserver.gwc.controller.GwcUrlHandlerMapping"> <constructor-arg ref="catalog" />
* <constructor-arg type="java.lang.String" value="/gwc/rest/web"/> <property
* name="alwaysUseFullPath" value="true" /> <property name="order" value="10" /> </bean>
*/
@Bean
GwcUrlHandlerMapping gwcDemoUrlHandlerMapping(Catalog catalog) {
GwcUrlHandlerMapping handler = new GwcUrlHandlerMapping(catalog, "/gwc/demo");
handler.setAlwaysUseFullPath(true);
handler.setOrder(10);
return handler;
}

@Bean
GwcUrlHandlerMapping gwcRestWebUrlHandlerMapping(Catalog catalog) {
GwcUrlHandlerMapping handler = new GwcUrlHandlerMapping(catalog, "/gwc/rest/web");
handler.setAlwaysUseFullPath(true);
handler.setOrder(10);
return handler;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,13 @@
* <p>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);
Expand Down

0 comments on commit 986836b

Please sign in to comment.