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

Router should have default 404 handler #172

Open
rylev opened this issue Jun 22, 2023 · 3 comments
Open

Router should have default 404 handler #172

rylev opened this issue Jun 22, 2023 · 3 comments

Comments

@rylev
Copy link

rylev commented Jun 22, 2023

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.

@karthik2804
Copy link
Collaborator

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.

@rylev
Copy link
Author

rylev commented Jun 30, 2023

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.

@ThorstenHans
Copy link

I think there are two ways of approaching this:

  1. The Router should provide the same behavior as popular/common routers provided by other frameworks of the particular language (JS/TS here).
  2. The Router should provide the same behavior across all Spin SDKs.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants