Java netflix外挂中的条标题
在调用端点时,我使用spring安全性在spring中运行了feign,而端点又调用了使用feign Gson的服务 终点:Java netflix外挂中的条标题,java,spring,http,header,netflix-feign,Java,Spring,Http,Header,Netflix Feign,在调用端点时,我使用spring安全性在spring中运行了feign,而端点又调用了使用feign Gson的服务 终点: @ApiOperation(value = "Cisco 1000v", notes = "Used with Nexus 1000v to Get configuration") @RequestMapping(value = "/cisco", method = RequestMethod.GET) public String getCisco(
@ApiOperation(value = "Cisco 1000v", notes = "Used with Nexus 1000v to Get configuration")
@RequestMapping(value = "/cisco", method = RequestMethod.GET)
public String getCisco(
@ApiParam(value = "Function to apply to switch", required = true) @RequestParam(value="Function") String function,
@ApiParam(value = "Hostname of device", required = true) @RequestParam(value="host") String hostname,
@ApiParam(value = "Username for device login", required = true) @RequestParam(value="user") String username,
@ApiParam(value = "Password of device", required = true) @RequestParam(value="pass") String password) throws IOException, SAXException, ParserConfigurationException {
CiscoNexus service = new CiscoNexus(hostname, username, password);
if (function.equals("port-profile")) {
return service.getPort();`
服务:
public class CiscoNexus {
private final String hostname, username, password;
public CiscoNexus(String hostname, String username, String password) {
this.hostname = hostname;
this.username = username;
this.password = password;
}
public String getPort() {
PortProfiles ports = Feign.builder()
.decoder(new GsonDecoder())
.encoder(new GsonEncoder())
.target(PortProfiles.class, "http://" + username + ":" + password + "@" + hostname);
System.out.println("Getting Port Profiles...");
ports.get();
return ports.get();
}
interface PortProfiles {
@RequestLine("GET /api/port-profile")
@Headers("Accept: application/json")
String get();
}
当我使用spring安全性调用端点时,我必须添加一个auth头,但似乎Faign保留了头并将其发送到无法正确响应的目标,这是可以避免的吗