How to serve static content using Webflux?

jabrena picture jabrena · Apr 26, 2017 · Viewed 8.9k times · Source

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.

Answer

Juan Medina picture Juan Medina · Apr 28, 2017

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