package cn.com.do1.component.gaiaportal.util;
import feign.*;
/**
* 客户端代理接口
*/
public interface FeignHttpClient {
/**
* 默认创建方法
* @param host
* @return
*/
static FeignHttpClient builder(String host) {
return Feign.builder()
.options(new Request.Options(10 * 1000, 10 * 6 * 1000 * 60))
.logger(new Logger.ErrorLogger())
.logLevel(Logger.Level.FULL)
.target(FeignHttpClient.class, host);
}
/**
* 获取token
* @return
*/
@RequestLine("GET /token?appId={appId}&secret={secret}")
String getToken(@Param("appId") String appId,@Param("secret") String secret);
/**
* 获取用户信息
* @return
*/
@Headers( {"X-Auth0-Token: {XAuth0Token}"})
@RequestLine("GET /wx/user/getUser?acode={acode}")
String getUserInfo(@Param("acode") String acode,@Param("XAuth0Token") String XAuth0Token);
}
FeignHttpClient feignHttpClient = FeignHttpClient.builder(GETUSERINFO_URL);
String userInfoJson= feignHttpClient.getUserInfo(acode,xAuth0Token);