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

fixed Method 'GET' already declared for route Error #62

Merged
merged 2 commits into from
May 27, 2020

Conversation

MomenNano
Copy link
Contributor

I fixed the error addressed on this issue 61

Method 'GET' already declared for route '/'
caused by setting empty get path route fastify.get('/', <function>) after registering with prefix.
and websocket will register two paths <prefix> and <prefix/> and two handler. which causes this error.

p.s. This is my first PR ever! so if something is not right, I would be thankful if you could guide me :)

Checklist

  • [✓ ] run npm run test and npm run benchmark
  • [ ✓] tests and/or benchmarks are included
  • documentation is changed or added
  • [ ✓] commit message and code follows Code of conduct

index.js Outdated Show resolved Hide resolved
Copy link
Member

@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.

LGTM
as nit I would just reverse the logic (it would be more readable):

if (routeOptions.path === routeOptions.prefix) {
 return
}

Copy link
Member

@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

@mcollina mcollina merged commit 91c9507 into fastify:master May 27, 2020
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

Successfully merging this pull request may close these issues.

3 participants