add params property like RadixRouter.lookup to RouteMatcher.matchAll
Describe the feature
I think this is more consistent with RadixRouter.lookup as I myself was hoping for a params property. The use-case comes from the implemetation of URL's wildcard pattern where there can be multiple urls have different path parameters.
Additional information
- [ ] Would you be willing to help implement this feature?
Hi. Can you please elaborate more about expected new feature how API looks like?
@pi0 Hello.
If there are two routing rules:
- /hello/:name
- /hello/:mine
The result matcher.matchAll('/hello/world') should return (assuming no other payload) is:
[
{ params: { name: 'world' } },
{ params: { mine: 'world' } }
]
But the current version of matchAll does not carry the params field. Therefore, for matched dynamic routes, I cannot know what the dynamic parameters are.
My current requirement is to match multiple dynamic routes and have them handled by multiple handlers at the same time. I would really appreciate it if this issue could be resolved.
From rou3 0.4x (#118) it is possible:
import { createRouter, addRoute, findRoute } from "rou3";
const router = createRouter();
addRoute(router, "", "/hello/:name", {});
addRoute(router, "", "/hello/:min", {});
/**
[
{ data: {}, params: [Object: null prototype] { name: 'world' } },
{ data: {}, params: [Object: null prototype] { min: 'world' } }
]
*/
console.log(findRoute(router, "GET", "/hello/world"));