Path Route different than requested?


#1

I’m trying to setup my services however I seem to have run into a snag.

Example case

Service:
    protocol: http
    host: api_example_org
    port: 80
    path: /
    name: user-service

Route:
    protocols: ["http", "https"]
    methods: ["POST"]
    hosts: null
    paths: /user/save
    strip_path: false

I want it to call the upstream service as api_example_org/save, however it calls it as api_example_org/user/save. If I set strip_path to true, then it’ll just do api_example_org which is also undesired. I’ve found a work around, but I don’t think that’s the right way of doing it, as I’d now be defining all my routes my routes would have a 1:1 mapping for all services.

Work around

Service:
    protocol: http
    host: api_example_org
    port: 80
    path: /save
    name: user-service

Route:
    protocols: ["http", "https"]
    methods: ["POST"]
    hosts: null
    paths: /user/save
    strip_path: true

Can anyone perhaps point me in the right direction on how to solve this problem? Is it with a plugin? (Transformer plugin doesn’t seem to do this) Is it with the configuration? Is this just simply not supported?

Thanks.

Excuse the url being api_example_org without dots … it was giving me an error saying “new users can’t post more than 2 links”


#2

Also looking for a answer to this


#3

Me to.
Without solution?


#4

Another Option is:

Service:
    protocol: http
    host: api_example_org
    port: 80
    path: /
    name: user-service

Route:
    protocols: ["http", "https"]
    methods: ["POST"]
    hosts: null
    paths: /user
    strip_path: true

Then when you call gateway.com/user/save it will route to backend.com/save. I don’t exactly see the major concern here, this is the nature of the beast when it comes to designing path based proxy routing.

Personally I recommend some restful taxonomy when making gateway routes to make them cleaner.

we do something like this for our routes:

/api/{ApiProviderName}/{MicroServiceName}/{version}

But then we full path the version out on the Service URL so we don’t let the wildcard paths get too creative/do too much besides enabling uri/query parameters and such.