Micro Application Route with Unknown Parameters

Hello,

I am having diccifulty with this little issue. So I am trying to match a complet route. It could be

/a/b/c/d/e/f/g

or

/a/b/c/d/e/f/g/h/i/j

Long story short, it can be very long or very short. I saw that you could do

$coll = new MicroCollection();

$login->setHandler('CollController', true);

$coll->get('/{a}/?{b}/?{c}', 'func');

$app->mount($coll);

And this will match

/a

/a/b

/a/b/c

but not /a/b/c/d

I would have to manually extend the route and handle all those variables. I was able to find /:params but when I attached that onto the route, like below, it did not work.

$coll->get('/{a}/:params', 'func');

Any help is much apprecitated!

Is that like a global catch-all route you want to achieve? Or you have regular/normal routes represented as MicroCollection, and this one specific route you want to handle?

In any case you'd need REGEXP to catch those I guess. Or if you know upfront maximum number of route parts - define them as you already did with example of 3 parts.

Hello, this is actually for an API for files. So the slashes represent directories.

Example: I could request C:/Users/pic.png or C:/Users/tom/Documents/Vacation/2017/04/24/pic.png

So the paths are relatively dynamic and I don't want to go adding 25 ?{file1}/?{file2} etc for optional route parameters.

Thanks

Is that like a global catch-all route you want to achieve? Or you have regular/normal routes represented as MicroCollection, and this one specific route you want to handle?

In any case you'd need REGEXP to catch those I guess. Or if you know upfront maximum number of route parts - define them as you already did with example of 3 parts.

IMHO, you'd better go with paremeter in that case - e.g. yourapp.tld/?do=files&path=fullPathHere or with pretty URLs: yourapp.tld/files/fullPathHere

OR you could also make use of notFound handler - to catch all routes there and decompose requested path and do desired action. It's just that Micro lacks internal dispatcher - so you'd have to handle response on your own (nothing difficult, I prefer total control over Request/Response anyways).