Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Idea] Allow routing based on partial or complete route params #1609

Open
nulltoken opened this issue Mar 14, 2022 · 6 comments
Open

[Idea] Allow routing based on partial or complete route params #1609

nulltoken opened this issue Mar 14, 2022 · 6 comments
Labels
Type: Idea This issue is a high-level idea for discussion.
Milestone

Comments

@nulltoken
Copy link
Contributor

What should we add or change to make your life better?

Hello,

It's currently possible to perform routing based on headers and query parameters.
How open would you be to extend RouteMatch to have it expose a RouteParam sub matcher. This one would be very similar to RouteQueryParameter (accepting values, a mode, ...).

Given, for instance, a route such as /api/tenants/{tenant_id}/do/something, it would be easy to redirect the requests based on the value of tenant_id.

Why is this important to you?

In order to meet regulations, data from those tenants should be stored in selected geographical locations.

Would this feature request feel appropriate, I'd be very willing to help contribute it through a Pull Request.

@nulltoken nulltoken added the Type: Idea This issue is a high-level idea for discussion. label Mar 14, 2022
@Tratcher
Copy link
Member

For path based routing we're limited to what's available in ASP.NET Core Routing. What you can do is use the route parameters to capture the tenant ID and then use this new 1.1 feature to check the tenant in middleware and dispatch to the desired cluster: #1538

@nulltoken
Copy link
Contributor Author

@Tratcher Thanks a lot for your feedback.

For path based routing we're limited to what's available in ASP.NET Core Routing

As I was having a little bit of spare time today, I've started to work on it (cf #1610). I shamelessly stole got heavily inspired by the QueryParametersMatcher and came up with a PathParametersMatcher (and friends...).

I've got a little something that seems to achieve what I was after. Would you be so kind to glance at it and see if that's something that would deserve a review?

@karelz
Copy link
Member

karelz commented Mar 24, 2022

Triage:

  • It is unclear if this is common request from users
  • There are few other ways how to do that recommended in the PR: [WIP] Introduce path parameter based routing #1610 (comment)
  • Note that routing is being migrated back into ASP.NET. YARP may be good place to experiment with additional improvements (and then backport later), or we might want to decide to do it directly in ASP.NET.

@karelz karelz added this to the Backlog milestone Mar 24, 2022
@kikisaeba
Copy link

Hello,

Fwiw, I would also be interested to see path param prefix based routing by Yarp.

@Amachua
Copy link

Amachua commented Apr 14, 2023

Having a similar issue, I searched on Internet if it is a common one and it appears that several project implements this kind of logic (see hapi or find-my-way) (as this routing behavior is developped on several application I suppose that's a pretty common request from the users) and I would be highly interested that the same approach be taken for the Microsoft reverse proxy.

@minhquang
Copy link

Yarp is a great but I would be excited to see that feature implemented in Yarp.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Idea This issue is a high-level idea for discussion.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants