forked from kptfh/feign-reactive
-
Notifications
You must be signed in to change notification settings - Fork 118
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 support of setting dynamic URI through method parameters #627
Comments
Original question from StackOverflow: https://stackoverflow.com/questions/65257778/using-dynamic-url-for-spring-reactivefeignclient |
Workaround with Java21 using @ReactiveFeignClient(name = "ReactiveDynamicUrlApi", url = BASE_URL, path = "v1/api/product", configuration = ReactiveDynamicUrlApi.RequestInterceptor.class)
interface ReactiveDynamicUrlApi {
String BASE_URL = "base-url";
@PostMapping(path = "{id}", headers = "Content-Type=application/json")
Mono<String> post(@RequestHeader(BASE_URL) String baseUrl, @PathVariable String id, @RequestHeader String token, @RequestBody Map requestBody);
class RequestInterceptor implements ReactiveHttpRequestInterceptor {
@Override
public Mono<ReactiveHttpRequest> apply(final ReactiveHttpRequest request) {
var uri = URI.create(request.headers().get(BASE_URL).getFirst() + request.uri().getPath());
request.headers().remove(BASE_URL);
return Mono.just(new ReactiveHttpRequest(request, uri));
}
}
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In Feign client I can change URI in runtime, without creating new instance of Feign client through builder, like:
But in ReactiveFeign I can't do so. Only through WebReactiveFeign .builder like this:
Is it possible to reuse the approach from Feign to ReactiveFeign client?
Thanks!
The text was updated successfully, but these errors were encountered: