Skip to content

Customize notFoundHandler #18

@yacinehmito

Description

@yacinehmito

In the process of migrating from Hono to Spiceflow, we found that there was no way of customizing notFoundHandler. When a route does not match, it always just outputs a 404 with a text body of "Not Found".

Hono provides the ability to customize this behavior through app.notFound(). Spiceflow does not provide such a method.

Would you be open to provide the ability to customize the notFoundHandler? If so, through which API?

Here are some options:

  • Like Hono, through the addition of a handler that can be chained on (like the current onError).
  • By providing in the context the information of which routes were matched. This would allow for a customization of the behavior by adding a last middleware, whose logic would roughly be "if there was no match, return whatever desired response and don't call next()".
  • By passing the handler in the Spiceflow constructor.

Let me know what you think.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions