@Override public RouterFunctions.Builder resources(String pattern, Resource location) { return add(RouterFunctions.resources(pattern, location)); }
@Override public RouterFunctions.Builder resources(Function<ServerRequest, Mono<Resource>> lookupFunction) { return add(RouterFunctions.resources(lookupFunction)); }
/** * Route requests that match the given pattern to resources relative to the given root location. * For instance * <pre class="code"> * Resource location = new FileSystemResource("public-resources/"); * RouterFunction<ServerResponse> resources = RouterFunctions.resources("/resources/**", location); * </pre> * @param pattern the pattern to match * @param location the location directory relative to which resources should be resolved * @return a router function that routes to resources * @see #resourceLookupFunction(String, Resource) */ public static RouterFunction<ServerResponse> resources(String pattern, Resource location) { return resources(resourceLookupFunction(pattern, location)); }
static RouterFunction<?> doRoute() { return resources(ROUTE, new ClassPathResource(PUBLIC)); } }
/** * Route requests that match the given pattern to resources relative to the given root location. * For instance * <pre class="code"> * Resource location = new FileSystemResource("public-resources/"); * RoutingFunction<Resource> resources = RouterFunctions.resources("/resources/**", location); * </pre> * @param pattern the pattern to match * @param location the location directory relative to which resources should be resolved * @return a router function that routes to resources */ public static RouterFunction<ServerResponse> resources(String pattern, Resource location) { Assert.hasLength(pattern, "'pattern' must not be empty"); Assert.notNull(location, "'location' must not be null"); return resources(new PathResourceLookupFunction(pattern, location)); }