spring-webfluxstatic-content

How to serve static content using Webflux?


I am learning webflux and I would like to know how to serve static content on a MicroService using webflux but I didn´t find information to do it.


Solution

  • Try this

    RouterFunction router = resources("/**", new ClassPathResource("public/"));
    

    UPDATE: Don't forget to specify a name of the static file in the URL when accessing it from outside, like localhost:8080/index.html