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

Added support for onBadUrl #134

Merged
merged 3 commits into from
Oct 7, 2019
Merged

Added support for onBadUrl #134

merged 3 commits into from
Oct 7, 2019

Conversation

delvedor
Copy link
Owner

@delvedor delvedor commented Oct 6, 2019

Now find-my-way offers the support for a separate handler in case of a bad url. If it's not configured, the behavior will be the same as before, which means calling the defaultRoute in case of the lookup and returning null in case of find.

Usage:

const router = require('find-my-way')({
  onBadUrl: (path, req, res) => {
    res.statusCode = 400
    res.end(`Bad path: ${path}`)
  }
})

Related: fastify/fastify#1884

Copy link
Collaborator

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@Eomm Eomm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! Thanks!

@delvedor delvedor merged commit cc29c06 into master Oct 7, 2019
@delvedor delvedor deleted the on-bad-url branch October 7, 2019 15:28
@delvedor delvedor mentioned this pull request Oct 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants