You can add an unannotated URI parameter (that can potentially be determined at runtime) and that will be the base path that will be used for the request. E.g.:
@FeignClient(name = "dummy-name", url = "https://this-is-a-placeholder.com")
public interface MyClient {
@PostMapping(path = "/create")
UserDto createUser(URI baseUrl, @RequestBody UserDto userDto);
}
And then the usage will be:
@Autowired
private MyClient myClient;
...
URI determinedBasePathUri = URI.create("https://my-determined-host.com");
myClient.createUser(determinedBasePathUri, userDto);
This will send a POST
request to https://my-determined-host.com/create
(source).
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…