Kong / kong

🦍 The Cloud-Native API Gateway and AI Gateway.
https://konghq.com/install/#kong-community
Apache License 2.0
38.89k stars 4.78k forks source link

allow for parameter mapping in path based routing #677

Closed ahmadnassri closed 7 years ago

ahmadnassri commented 8 years ago

e.g. allow request_path to contain values such as /api/{foo}/bar which map to the upstream_url /upstream/my/api/bar/{foo}

this could also be more globally addressed with regex matching groups e.g.

request_url = '/api/(.+)/bar`
upstream_url = '/upstream/my/api/bar/$1'
ayush commented 8 years ago

Native support for path parameters in Kong seems like a pretty significant missing piece.

Right off the bat, I want to say that it is clear to me that Kong can proxy to path parameter based APIs. Let us say I have two backend GET APIs /pet/{petId}/get-image and /pet/{petId} If I want Kong to be able to proxy to both, I can simply create an API with request_path as /pet. This will make sure that http://kongserver/pet/123 will be forwarded to http://upstreamserver/pet/123 and http://kongserver/pet/123/get-image will be forwarded to http://upstreamserver/pet/123/get-image (thanks to @travisyates for clarifying this)

However, not having native support for path parameters is problematic. There is probably more to it but I see two resulting side effects of Kong not supporting path parameters:

Kong Blindness

In the above example, Kong is blind to the difference between these two APIs. Even though these are two very different APIS, Kong cannot tell them apart. This leads to problems with using plugins and other features of Kong effectively.

Let us say that Kong did support path parameters and let me define these two APIs separately:

In my use case, I want to allow anonymous access to /pet/{petId}/get-image while securing access to /pet/{petId}. Using ACL plugin I would be able to do it but only if Kong allowed me to add these two as different APIs. Right now, Kong cannot tell the difference between these two. And thus I cannot secure these two separately.

Additional complexity of collapsing multiple APIs

As a developer using Kong, I now have to parse all my API definitions and if there are situations like the above /pet/{petId}/get-image and /pet/{petId}, I'll need to deal with the complexity of collapsing them into one API. This kinda sucks. I was working on a project which takes swagger api definitions and puts them in Kong with the right security. This limitation of Kong introduces an impedance mismatch which does not have any ideal solution other than Kong natively supporting path parameters.

ahmadnassri commented 8 years ago

while this is a limitation of the functionality, i wouldn't say its a "significant missing piece"

Kong aspires to be a solution for ALL API providers, and the described is just one of many abstractions and methods used. we'll have to balance that equally against other feature requests and with the community's feedback and support we can prioritize appropriately :)

ayush commented 8 years ago

@ahmadnassri Path parameters are widely used and are even part of open standards like swagger. Completely ignoring them in an API middleware does not seem right. Even Amazon API Gateway has some support for them.

I don't wish to be incessant about how we classify this :) but in the interest of community's feedback and support to help Kong developers prioritize, I'd certainly qualify it as a "significant missing piece".

ahmadnassri commented 8 years ago

nobody said anything about "Completely ignoring" them :) just talking about prioritizing features.

there. are. many. feature. requests so we're looking for community feedback for help in prioritization!

ahmadnassri commented 8 years ago

related: the official spec: RFC 6570 describing proper URL Templating usage.

sidharthachatterjee commented 8 years ago

@ahmadnassri Any update on when we can expect this?

BrianHutchison commented 8 years ago

+1

This would meet a major use-case/need of ours.

3dbrows commented 8 years ago

+1

eitanpo commented 8 years ago

+1

RossJayJones commented 8 years ago

+1

haikuo81 commented 8 years ago

+1

andyfleming commented 8 years ago

Wildcard/parameter mapping would be helpful. In my specific use case I'm looking to do something like:

/something/{alphanumeric}/whatever to be routed to /whatever and I want to add the header x-id: {alphanumeric}

bradwood commented 8 years ago

+1

matangiz commented 8 years ago

+1

lucas-cegatti commented 8 years ago

+1

vitorsdcs commented 8 years ago

+1

merlindorin commented 8 years ago

+1, really need it, we are stucked now with this missing feature and we have review our mircoservice architecture :'(

The main problem is related to API depth in our services. For example, I can't have different microservice for an endpoint like /users/john/organizations and /users/john/projects. The unique base path that we can handle with kong is /users so... we can have just one service behind (and not one for /users/:username/organizations and /users/:username/projects).

merlindorin commented 8 years ago

+1 for RFC6570

kintetsu commented 8 years ago

+1

dankennedy commented 8 years ago

+1

goraniliev commented 8 years ago

+1

erutherford commented 7 years ago

@ahmadnassri is there any movement on this? We're currently implementing a work around with a nginx proxy in between kong and our services, but this is a less than ideal setup. We'd definitely prefer to have kong handle this path matching on it's own. If you could provide the likelihood or progress on this issue it'd aid us greatly in planning out our future direction.

thibaultcha commented 7 years ago

This is still on our roadmap but no work has been done as of today yet. Expect such a feature for 0.11 or 0.12, eventually.

Roam-Cooper commented 7 years ago

Any word on this? Kong is unusable for modern apis without this feature. It's 2016; any petty arguments about this are null and void, in my opinion. Almost every major api in the world uses url parameters.

drabiter commented 7 years ago

+1

in other case you may want to expand metrics from statsd per uri, so this could help that also.

kvaillant commented 7 years ago

+1

tookko commented 7 years ago

+1

thedodd commented 7 years ago

+1

rudijs commented 7 years ago

+1

nemccarthy commented 7 years ago

+1

Krieke commented 7 years ago

+1

SriramKeerthi commented 7 years ago

Any updates on timelines for this issue? We're about to invest a lot of time into Kong in our stack and this is a deal-breaking issue for us.

Krieke commented 7 years ago

@SriramKeerthi +1 We are also investigating different API gateway sollutions: Kong vs Tyk vs ... I has come to my attention that some pull request remains open for several months in despite.

thibaultcha commented 7 years ago

Hey all, just a quick update on this as we realize it's a pretty big deal for a lot of people:

We're slowly making our way through our list of priorities, but now that 0.10 is out and contains the new router, we're planning to build this by Q2 this year. The new router is built with extensibility in mind, especially for regex and parameters mapping, so we're now on track for this!

Cheers

alfredogordian commented 7 years ago

Nice, I really looking forward for Q2 :) , In the meantime, does anybody has a partial solution to this issue? I would like to read some ideas

ikouchiha47 commented 7 years ago

@driagongit one solution is to have a router before the kong clusters, which supports such url redirection. And then redirect url to kong ..

merlindorin commented 7 years ago

clearly :/ ... In HA architecture, this need a set of extra services... more services, more complexity, more complexity, more 💸

(#useless answer, just 😢 )

hizorro88 commented 7 years ago

+1

nizq commented 7 years ago

+1

mrproper commented 7 years ago

I ended up finding this after running into the same issue....to be honest i was a little surprised that path parameters dont exist. for example api.tld/foo/$id/bar I want restricted to GET api.tld/foo/$id/betsy I want restricted to POST

in current kong i basically have to allow: api.tld/foo GET,POST

Seems like a bit of an oversight or am i just missing something completely?

HenryChelsea commented 7 years ago

+1. Modern apis need this. (RFC6570)

remihrt commented 7 years ago

+1

serghei-ilin commented 7 years ago

+1

Jimflip commented 7 years ago

"we're planning to build this by Q2 this year. " <---- so what's the new estimate?

nehasupnfan commented 7 years ago

Any movement on this??

thibaultcha commented 7 years ago

Hi,

Yes, we are still planning on building this soon. This estimate is still somewhere around this month or the next one.

After updating the router to support much better use cases already, our focus has been more on things like removing the Serf dependency, improving our new DNS resolver, improving our configuration options for better usability (considering the current use cases), and fixing a good amount of bugs. We've also invested a good amount of time on-boarding new developers on the team (hi @p0pr0ck5 @bungle :wink:), and researching/designing our next features and refactors. On top of that, as a company Mashape also has its own business requirements and priorities on which focus was also given on.

That said, our Q2, 0.11/0.12 estimation is still standing, but I hope that this highlights not the fact that we are disinterested in this feature, but rather that we are/were taking care of higher priorities at this point :)

ghost commented 7 years ago

+1

ramo-karahasan-riechardt commented 7 years ago

+1

lodow commented 7 years ago

Please do not comment with "+1". Use thumbs emoji instead so we can keep important information visible. Thank you 😃

williamhorstkamp commented 7 years ago

This would be exceptionally useful. Looking forward to this release!