org.ileler.swjp.JsonParamConfigForWebFlux Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of spring-web-json-param Show documentation
Show all versions of spring-web-json-param Show documentation
Allow users to freely use json parameters in spring-web projects.
The newest version!
package org.ileler.swjp;
import org.springframework.core.MethodParameter;
import org.springframework.core.ReactiveAdapterRegistry;
import org.springframework.http.codec.ServerCodecConfigurer;
import org.springframework.ui.Model;
import org.springframework.web.reactive.BindingContext;
import org.springframework.web.reactive.config.WebFluxConfigurer;
import org.springframework.web.reactive.result.method.annotation.AbstractMessageReaderArgumentResolver;
import org.springframework.web.reactive.result.method.annotation.ArgumentResolverConfigurer;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;
import reactor.core.publisher.MonoSink;
import java.util.HashMap;
import java.util.Map;
/**
* Author: [email protected]
*/
public class JsonParamConfigForWebFlux implements WebFluxConfigurer {
public void configureArgumentResolvers(ArgumentResolverConfigurer configurer) {
configurer.addCustomResolver(new HandlerMethodArgumentResolverForFlux());
}
class HandlerMethodArgumentResolverForFlux extends AbstractMessageReaderArgumentResolver {
private static final String JSONBODYATTRIBUTE = "JSON_REQUEST_BODY";
public HandlerMethodArgumentResolverForFlux() {
super(ServerCodecConfigurer.create().getReaders(), ReactiveAdapterRegistry.getSharedInstance());
}
@Override
public boolean supportsParameter(MethodParameter parameter) {
return JsonParamResolver.supportsParameter(parameter);
}
public Mono