Spring boot 如何配置Spring Sidecar的内部RestController和假客户端

Spring boot 如何配置Spring Sidecar的内部RestController和假客户端,spring-boot,netflix-zuul,openfeign,sidecar,Spring Boot,Netflix Zuul,Openfeign,Sidecar,我有一个microservices场景,其中一个Sidecar(springboot应用程序)映射python Web服务器的端点 python服务器监听5000并执行计算,因此我们决定在URI中用“calc”前缀映射其主页,因此我们有以下配置: eureka: [omissis] #it works sidecar: port: 5000 health-uri: http://${sidecar.hostname}:${sidecar.port}/health.json

我有一个microservices场景,其中一个Sidecar(springboot应用程序)映射python Web服务器的端点

python服务器监听5000并执行计算,因此我们决定在URI中用“calc”前缀映射其主页,因此我们有以下配置:

eureka:
  [omissis] #it works
sidecar:
   port: 5000
   health-uri: http://${sidecar.hostname}:${sidecar.port}/health.json
   home-page-uri: http://${sidecar.hostname}:${sidecar.port}/
   hostname: localhost
server:
  port: 2323
  servlet:
    context-path: /pye

zuul:
  routes:
      calc:
          url: localhost:5000/
然后,我在Sidecar microservice中引入了一个新的REST控制器,即:

@RestController
@RequestMapping("git")
public class GitController {

@GetMapping("/")
public List<String> getBranchesAlias(@RequestHeader("Authorization") String oauth2Token,
        @RequestHeader(value = "OIDC_access_token", required = false) String oidAccessToken) {
        //returns a list of branches from a git repository
    return getBranches(oauth2Token, oidAccessToken);
   }
}
正如我们在第一行日志中看到的,主机是“localhost:5000”。 我想做的是,对“/git/**”的调用不会重定向到python,而是由RestController提供服务

我怎样才能得到呢?
谢谢

我的最终解决方案是,这是不可能的:如果插入RestController,Sidecar也不能正常工作。

我的最终解决方案是,这是不可能的:如果插入RestController,Sidecar也不能正常工作

@FeignClient(name = "python-engine")
public interface PythonEngineClient {
@GetMapping(value = "/pye/git/", produces = MediaType.APPLICATION_JSON_VALUE)
List<String> getBranches(@RequestHeader("Authorization") String oauth2Token,
        @RequestHeader(value = "OIDC_access_token", required = false) String oidAccessToken);
}
DEBUG s.n.w.p.http.HttpURLConnection - sun.net.www.MessageHeader@647d9996 pairs: {GET /pye/git/branches HTTP/1.1: null}{Accept: application/json}{Authorization: Bearer [omissis] }{User-Agent: Java/1.8.0_232}{Host: localhost:5000}{Connection: keep-alive}
DEBUG s.n.w.p.http.HttpURLConnection - sun.net.www.MessageHeader@88037215 pairs: {null: HTTP/1.1 404 NOT FOUND}{Content-Length: 232}{Content-Type: text/html}{Date: Fri, 14 Feb 2020 08:53:49 GMT}{Server: waitress}
ERROR o.a.c.c.C.[.[.[.[dispatcherServlet] - Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is 
feign.FeignException: status 404 reading PythonEngineClient#getBranches(String,String)] with root cause
feign.FeignException: status 404 reading PythonEngineClient#getBranches(String,String)
at feign.FeignException.errorStatus(FeignException.java:78)