The following (simplified) code is deployed as a service.
@Configuration
public class RouterConfig {
private static String htmlContent;
static {
try {
InputStream res = new ClassPathResource("static/index.html").getInputStream();
htmlContent = new String(res.readAllBytes());
} catch (IOException e) {
//
System.out.println("ERROR");
}
}
@Bean
public RouterFunction<ServerResponse> indexRouter() {
return route(GET("/"),
request -> Optional.ofNullable(htmlContent)
.map(content ->
ServerResponse.ok()
.contentType(MediaType.TEXT_HTML)
.bodyValue(content))
.orElse(ServerResponse.status(HttpStatus.BANDWIDTH_LIMIT_EXCEEDED)
.build()));
}
@Bean
public RouterFunction<ServerResponse> resourceRouter() {
return RouterFunctions.resources("assets/**", new ClassPathResource("assets/"))
.and(RouterFunctions.resources("fonts/**", new ClassPathResource("fonts/")))
.and(RouterFunctions.resources("img/**", new ClassPathResource("img/")))
.and(RouterFunctions.resources("/**", new ClassPathResource("/")));
}
}
If I navigate to the root of my website then it can find the index.html file, which is great.
I defined a 'resource router' which is basically a RouterFunction which accesses my assets, fonts, imgs etc. (See code snippet)
However none of the resources are loaded into my website. Instead I get 404 errors :
My files in my jar file look like this :
And the resources are accessed from the index file like this : 
How do you correctly configure assets when using spring-webflux Router Functions?

