Spring Cloud

Spring Webflux 学习笔记

2020-01-08  本文已影响0人  王广帅
Consumer<ClientCodecConfigurer> consumer = configurer -> {
        CustomDecoder customDecoder = new CustomDecoder();
        configurer.customCodecs().decoder(customDecoder);
        configurer.customCodecs().withDefaultCodecConfig(config ->
            customDecoder.maxInMemorySize(config.maxInMemorySize())
        );
}

WebClient webClient = WebClient.builder()
        .exchangeStrategies(strategies -> strategies.codecs(consumer))
        .build();
@Configuration
public class MyConfig {

    @Autowired
    public void setHandlerMapping(RequestMappingHandlerMapping mapping, UserHandler handler) 
            throws NoSuchMethodException {

        RequestMappingInfo info = RequestMappingInfo
                .paths("/user/{id}").methods(RequestMethod.GET).build(); 

        Method method = UserHandler.class.getMethod("getUser", Long.class); 

        mapping.registerMapping(info, handler, method); 
    }

}

1,Inject target handlers and the handler mapping for controllers.
2,Prepare the request mapping metadata.
3,Get the handler method.
4,Add the registration.

上一篇下一篇

猜你喜欢

热点阅读