We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
In Feign client I can change URI in runtime, without creating new instance of Feign client through builder, like:
@FeignClient(name = "dummy-name", url = "this-is-a-placeholder") public interface MyClient { @PostMapping(path = "/create") UserDto createUser(URI baseUrl, @RequestBody UserDto userDto); } //call service: URI determinedBasePathUri = URI.create("https://my-host.com"); myClient.createUser(determinedBasePathUri, userDto);
But in ReactiveFeign I can't do so. Only through WebReactiveFeign .builder like this:
IcecreamServiceApi client = WebReactiveFeign //WebClient based reactive feign .<IcecreamServiceApi>builder() .target(IcecreamServiceApi.class, "http://www.myUrl.com")
Is it possible to reuse the approach from Feign to ReactiveFeign client?
Thanks!
The text was updated successfully, but these errors were encountered:
Original question from StackOverflow: https://stackoverflow.com/questions/65257778/using-dynamic-url-for-spring-reactivefeignclient
Sorry, something went wrong.
Workaround with Java21 using ReactiveHttpRequestInterceptor and @RequestHeader:
ReactiveHttpRequestInterceptor
@RequestHeader
@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)); } } }
No branches or pull requests
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: