Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ParameterizedTypeReference to ModifyRequestBodyGatewayFilterFactory #2635

Closed
wuxudong opened this issue Jun 7, 2022 · 0 comments · Fixed by #3011
Closed

Add ParameterizedTypeReference to ModifyRequestBodyGatewayFilterFactory #2635

wuxudong opened this issue Jun 7, 2022 · 0 comments · Fixed by #3011

Comments

@wuxudong
Copy link

wuxudong commented Jun 7, 2022

Is your feature request related to a problem? Please describe.
ModifyRequestBodyGatewayFilterFactory only support Class inClass, it is not compatible with generic type.
expected code:

builder.routes()
  .route("test_route", r -> r.path("/**").filters(f ->
          f.modifyRequestBody(
                  new ParameterizedTypeReference<MultiValueMap<String, String>>() {},
                  new ParameterizedTypeReference<MultiValueMap<String, String>>() {},
                  (RewriteFunction<MultiValueMap<String, String>, MultiValueMap<String, String>>) (exchange, body) -> Mono.just(body))))

Describe the solution you'd like
serverRequest.bodyToMono support both class and ParameterizedTypeReference.
I think ModifyRequestBodyGatewayFilterFactory should support both of them too.

ServerRequest


	/**
	 * Extract the body to a {@code Mono}.
	 * @param elementClass the class of element in the {@code Mono}
	 * @param <T> the element type
	 * @return the body as a mono
	 */
	<T> Mono<T> bodyToMono(Class<? extends T> elementClass);

	/**
	 * Extract the body to a {@code Mono}.
	 * @param typeReference a type reference describing the expected response request type
	 * @param <T> the element type
	 * @return a mono containing the body of the given type {@code T}
	 */
	<T> Mono<T> bodyToMono(ParameterizedTypeReference<T> typeReference);

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Status: Done
2 participants