-
Notifications
You must be signed in to change notification settings - Fork 257
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
Allow for more granular route matching in Spin #1923
Comments
I'm not necessarily opposed to this but just want to note that V2 manifests help with a workaround in some (not all!) situations: [[trigger.http]]
route = "/..."
component = "bartholomew"
[[trigger.http]]
route = "/spin/..."
component = "proxy"
[[trigger.http]]
route = "/spin/v1/..."
component = "bartholomew" |
@lann that works in that specific case but if someone adds a |
@lann one other practical issue is that it increases the memory usage since the extra component mounts end up creating their own copy of the static files |
With v2 manifests that shouldn't happen if you point two triggers at one component. If mounts are duplicated in that case it's a bug. |
Oh ok - I was testing with just |
@karthik2804 did Spin v2 and the v2 manifest help here? I'm assuming we'd still like this issue to track nested wildcard route support (eg |
Do we have a good sense of what we want from this feature? It seems like the ask is specifically for a kind of "single level" wildcard, i.e. like Some challenges I see here are:
Any other design considerations? |
The use case I have had requires only a single level of wildcard but based on @lann's workaround above, it could be done by adding multiple triggers.
|
@karthik2804 Sorry I maybe confused the question by giving the Suppose I have a trigger (Potentially nastier is the multiple case of |
@karthik2804 Is your comment about the multiple trigger workaround suggesting that this is no longer important (at least to you) and could be dropped from the 2.1 list? I am not sure if we have any other users asking after this yet. |
@itowlson, it was in reference to the following
The workaround above solves the issue I ran into (I have yet to test). On the sharing multiple matched segments, |
I chatted with Karthik offline and some alternative ideas for capturing
|
FYI: From a customer perspective, this would be a really useful feature to have - personally, I would vote for named wildcards, but I'd be happy with any workable solution for enabling more powerful wildcard paths 😁 |
Regular Expressions are The Swiss Army Knife of Text Processing. Flexible routing structure can give me more flexible / micro-sized modularization which I can split my app into more smaller wasms. Isn't that the recommended direction for wasm architecturing? |
Given that #2305 is nearing completion, one thing I'd like to explore is using that service chaining feature to enable advanced routing scenarios via a routing component, especially for something like regular expressions which may not be appropriate for all users. |
I started exploring this and I am getting very hung up on potential ambiguities. For example, if the app has routes And then I started thinking "what if we just reject applications with this kind of ambiguous overlap", requiring any pair of routes to be either disjoint or in a subset relationship. Because if you have Another possibility, which lines up with some programmatic routers, is to make it order-dependent: first (or last) match wins. Pre-1.0 Spin had that rule, and we replaced it with longest match because it provides more reliability as manifests change (e.g. triggers getting tacked on the end via Finally, the original issue asked for single-segment match only in a trailing position, e.g. a I feel like I'm overthinking this because lots of routers just do this stuff, so, save me from myself folks: how should this behave? |
Could we lean into routefinder here? If we introduce named parameters (e.g. Also, I'm not a big fan of supporting The question then is how do we surface named captures to a guest? Immediately I'm not opposed to propagating captures as The major benefit of creating an isomorphism to routerfinder (or similar syntax) is that we can take advantage of the ranking and ordering of routes to handle all the ambiguities mentioned. |
I like I'd be fine with e.g. |
Yeah sorry I will look at routefinder precedence: thanks. |
Currently, the route matching in spin can be of two forms
It would be helpful in certain cases if the route matching allowed more granularity. For an example consider the case of a Bartholomew app with a proxy component.
With such a configuration, the
proxy
component would match the route/spin/index
but not/spin/v1/index
. Thus allowing theproxy
to handle one specific subset of the routes whilebartholomew
handles the rest.There is potential for another level of granularity where we could define something like
Which would only match
/spin/index/test
but not/spin/index/something-else
Thoughts?
The text was updated successfully, but these errors were encountered: