Open rylev opened 1 year ago
The router does support the match-all syntax which can be added as the last entry to catch all routes that do not match. It is how itty-router is implemented. Would that be sufficient in this case.
router.all("*", ...)
I personally think that there should be no default route handling because there are cases where I would want to use a router to be triggered only on specific routes.
I suppose that would be sufficient. I simply found it surprising that the router wasn't catching unknown routes, but if we give the user a good way to do this (and display it prominently in the docs, that is probably good enough.
I think there are two ways of approaching this:
Initially, I thought option 2 would be the best way to go. Option 2 would be especially useful for developers using multiple languages to craft Spin applications.
On the flip side, option 1 would smoothen the adoption for JS developers, because they expect the router to behave in a certain way.
When a request goes through the router for which there is no route defined, a very cryptic message is thrown. We should at least provide some sort of default handling of an unrecognized request.