返回值可以直接使用feign.Response 即可
1、feign客户端调用
注意点,feign中header可以放在 @RequestMapping中进行处理
@FeignClient( contextId = "loginInter",value = SystemServiceName.AUTH_SERVICE_USERCENTER_SAAS)
public interface LoginInter {
//通过拿着cas获取的tickt获取用户信息
@RequestMapping(value = "/api/user/info/login",method = RequestMethod.POST,headers = {"content-type=application/json"})
public feign.Response loginGetUserByCasTicket(@RequestBody JSONObject jsonObject);
}
2、 调用feign客户端位置
其中 IoUtil 是 hutool包里面的 cn.hutool.core.io
JSONObject jsonObject = new JSONObject();
Response response = loginInter.loginGetUserByCasTicket(jsonObject);
Response.Body body1 = response.body();
//获取body .处理。 IoUtil是 hutool包里面的 cn.hutool.core.io
String body = IoUtil.read(body1.asReader(Charset.forName("utf-8")));
//返回body结果
logger.debug("调用用户认证接口返回数据为{}",body);
//统一的用户token,操作【header】
String casToken = response.headers().get("token")+"";