These are chat archives for spring-cloud/spring-cloud

9th
Jun 2017
Ishara Samantha
@ishara
Jun 09 2017 10:54
@dsyer this is regarding spring-cloud/spring-cloud-netflix#77 , I have created sample project to recreate issue , https://github.com/ishara/zuul-routes-issue , can u please check
Dave Syer
@dsyer
Jun 09 2017 11:04
Looks like it's working to me
What's the problem?
BTW It's not really to do with #77 (that was closed like 3 yrs ago).
But anyway...
what was the problem?
Ishara Samantha
@ishara
Jun 09 2017 11:08
check the heotes link url , additional "rest-api" part
{"code":"1","name":"One","links":[{"rel":"self","href":"http://localhost:8080/api-gateway/rest-url/rest-api/itemDetails"}]}
Dave Syer
@dsyer
Jun 09 2017 11:09
I see
You have an extra path element in there
Ishara Samantha
@ishara
Jun 09 2017 11:09
yes
Dave Syer
@dsyer
Jun 09 2017 11:09
The link is generated by your app
So I would look there
Ishara Samantha
@ishara
Jun 09 2017 11:09
yes
If we remove contextPath from rest-api, this will work. But I can not remove contextPath, we have multiple war files in tomcat.
Dave Syer
@dsyer
Jun 09 2017 11:13
Bummer
Anyway, this is the expected behaviour.
Ishara Samantha
@ishara
Jun 09 2017 11:14
HATEOAS link break ?
Dave Syer
@dsyer
Jun 09 2017 11:16
The link builder has all the information it needs, I think
It just doesn't use it quite the way you want
If there isn't a suitable API in Spring HATEOAS I guess could open a ticket there
It's tricky this stuff
But I'm not sure we can do any more than we are in the Zuul layer
Ishara Samantha
@ishara
Jun 09 2017 11:22
yes , this is not zuul layer issue, may be in ServletUriComponentsBuilder
Any workaround or temp solution
Dave Syer
@dsyer
Jun 09 2017 11:24
You can include the context path in the caller
e.g.
zuul:
  addProxyHeaders: true
  routes:
    api:
      path: /rest-url/**
      url: http://localhost:9090
      stripPrefix: true
$ curl localhost:8080/api-gateway/rest-url/rest-api/item
{"code":"1","name":"One","links":[{"rel":"self","href":"http://localhost:8080/api-gateway/rest-url/rest-api/itemDetails"}]}
If there is a context path , it seems crazy to try and hide that from the caller
So this seems like the correct behaviour to me
If you desperately need to hide it then you kind of need a way to run your tomcats differently. E.g. add an active proxy layer in between the callers and the tomcat backend.
That seems like a really gimcrack solution though (truly that is a "workaround")
Ishara Samantha
@ishara
Jun 09 2017 11:28
Got it , thank you very much