Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

webflux equivalent of WebMvcConfigurer

I'm migrating an app form spring mvc to spring webflux and I can't figure out what's the equivalent of this webMvc conf :

@Configuration
public class PathMatchingConfigurationAdapter implements WebMvcConfigurer {

    @Override
    public void configureContentNegotiation(ContentNegotiationConfigurer configurer) {
        configurer.favorPathExtension(false);
    }
}

any idea is welcome

like image 455
Seb Avatar asked Oct 24 '17 15:10

Seb


People also ask

Can I use Springmvc and WebFlux together?

both infrastructure will compete for the same job (for example, serving static resources, the mappings, etc) mixing both runtime models within the same container is not a good idea and is likely to perform badly or just not work at all.

Why WebFlux is non-blocking?

Spring 5.0 has introduced WebFlux to support the reactive web in a non-blocking manner. WebFlux is based on the reactor API, just another awesome implementation of the reactive stream. Spring WebFlux supports reactive backpressure and Servlet 3.1+ with its non-blocking I/O.

Is WebFlux part of spring boot?

Spring 5 includes Spring WebFlux, which provides reactive programming support for web applications. In this tutorial, we'll create a small reactive REST application using the reactive web components RestController and WebClient. We'll also look at how to secure our reactive endpoints using Spring Security.

Which API is spring WebFlux built on?

Spring WebFlux is a web framework that's built on top of Project Reactor, to give you asynchronous I/O, and allow your application to perform better. If you're familiar with Spring MVC and building REST APIs, you'll enjoy Spring WebFlux.


1 Answers

Spring WebFlux does not support suffix pattern matching, see SPR-15639 for more information on the rationale behind that decision.

As a replacement, you can use a ParameterContentTypeResolver which does the same thing but with a query parameter like format=json. You can configure this with:

@Configuration
public class WebFluxConfig implements WebFluxConfigurer {

  public void configureContentTypeResolver(RequestedContentTypeResolverBuilder builder) {
    builder.parameterResolver().headerResolver();
  }
}
like image 189
Brian Clozel Avatar answered Oct 28 '22 20:10

Brian Clozel