ThreeMammals / Ocelot

.NET API Gateway
https://www.nuget.org/packages/Ocelot
MIT License
8.39k stars 1.64k forks source link

DownstreamSchema appending to address when not necessary #469

Closed aadupirn closed 6 years ago

aadupirn commented 6 years ago

New Feature

When consul returns an address that includes the http or https prefix when providing services after a service registry query Ocelot should recognize that the DownstreamScheme field needs not be applied.

Motivation for New Feautre

Ocelot will append the DownstreamScheme field in front of an address even if it's not necessary, resulting in downstream paths like http://http://localhost:9002/products/1. This could be avoided with a simple regex expression to remove the scheme provided from the service registry if there is one.

This is more of a QoL issue but it did result in me butting my head against a wall for a couple hours trying to figure out why my gateway wasn't getting to my service.

TomPallister commented 6 years ago

@aadupirn thanks for your interest in Ocelot, this makes sense! I will get round to it asap. I would classify it as a bug I think which means I will do it sooner than features! Thanks for your input into the project.

TomPallister commented 6 years ago

@aadupirn I had a look into this issue and tracking back the changes I can see that in a previous issue we decided not to support http or https in the Consul Address. I've updated the Ocelot docs to show this.

The main problem is what takes priority if a user sets both, this will always be different for different users :/ so it is probably better for Ocelot to just no allow it. Also reading Consul docs doesnt seem to make sense to put scheme into the address field :/

Sorry for not changing the behaviour hopefully this makes sense!