RestClientConfig.java
1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package vion.config;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestClient;
import org.springframework.web.util.DefaultUriBuilderFactory;
/**
* @author HlQ
* @date 2024/7/19
*/
@Configuration
@Slf4j
public class RestClientConfig {
@Bean(name = "bongRestClient")
public RestClient getBongRestClient() {
return RestClient.builder()
.baseUrl("https://proapi.xbongbong.com")
.build();
}
@Bean(name = "oDingRestClient")
public RestClient getODingRestClient() {
// disable url encoding
// 在对 + 号进行处理时,默认对该字符不处理
var uriBuilderFactory = new DefaultUriBuilderFactory("https://oapi.dingtalk.com");
uriBuilderFactory.setEncodingMode(DefaultUriBuilderFactory.EncodingMode.NONE);
return RestClient.builder()
.uriBuilderFactory(uriBuilderFactory)
.build();
}
@Bean(name = "dingRestClient")
public RestClient getdingRestClient() {
return RestClient.builder()
.baseUrl("https://api.dingtalk.com")
.build();
}
}