我在Spring Boot上编写了一个支付系统。为了与支付提供商集成,我使用FeignClient。我看到对于不同的操作(存款和取款),不同的提供者可以使用不同的url。FeignClient允许不同的频繁使用不同的URL?
我的意思是:
@FeignClient(name = "ProviderName")
public interface ProviderClient {
// Request to Provider deposit URL
@PostMapping(consumes = MediaType.APPLICATION_JSON_VALUE,
produces = MediaType.TEXT_HTML_VALUE)
DeposiResponse deposit(DeposiRequest request);
// Request to Provider withdraw URL
@PostMapping(consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE,
produces = MediaType.TEXT_XML_VALUE)
WithdrawResponse withdrawPrepare(@RequestBody WithdrawRequest withdrawRequest);
}
例如:
deposit: "https://pay.skrill.com/"
withdraw: "https://www.skrill.com/app/pay.pl"
您可以在每个Feign Client的方法中声明不同的路径:
// Request to Provider first URL
@PostMapping(path="/url1", consumes = MediaType.APPLICATION_JSON_VALUE,
produces = MediaType.TEXT_HTML_VALUE)
DeposiResponse deposit(DeposiRequest request);
// Request to Provider second URL
@PostMapping(path="/url2", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE,
produces = MediaType.TEXT_XML_VALUE)
WithdrawResponse withdrawPrepare(@RequestBody WithdrawRequest withdrawRequest);