{"action":"created","issue":{"url":"https://api.github.com/repos/fastify/fastify/issues/862","repository_url":"https://api.github.com/repos/fastify/fastify","labels_url":"https://api.github.com/repos/fastify/fastify/issues/862/labels{/name}","comments_url":"https://api.github.com/repos/fastify/fastify/issues/862/comments","events_url":"https://api.github.com/repos/fastify/fastify/issues/862/events","html_url":"https://github.com/fastify/fastify/pull/862","id":308349509,"number":862,"title":"Better handling of 404 routes","user":{"login":"delvedor","id":4865608,"avatar_url":"https://avatars0.githubusercontent.com/u/4865608?v=4","gravatar_id":"","url":"https://api.github.com/users/delvedor","html_url":"https://github.com/delvedor","followers_url":"https://api.github.com/users/delvedor/followers","following_url":"https://api.github.com/users/delvedor/following{/other_user}","gists_url":"https://api.github.com/users/delvedor/gists{/gist_id}","starred_url":"https://api.github.com/users/delvedor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/delvedor/subscriptions","organizations_url":"https://api.github.com/users/delvedor/orgs","repos_url":"https://api.github.com/users/delvedor/repos","events_url":"https://api.github.com/users/delvedor/events{/privacy}","received_events_url":"https://api.github.com/users/delvedor/received_events","type":"User","site_admin":false},"labels":[{"id":750220462,"url":"https://api.github.com/repos/fastify/fastify/labels/bugfix","name":"bugfix","color":"e99695","default":false},{"id":641286043,"url":"https://api.github.com/repos/fastify/fastify/labels/discussion","name":"discussion","color":"c5def5","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":6,"created_at":"2018-03-25T13:25:05Z","updated_at":"2018-03-25T20:32:43Z","closed_at":null,"author_association":"OWNER","pull_request":{"url":"https://api.github.com/repos/fastify/fastify/pulls/862","html_url":"https://github.com/fastify/fastify/pull/862","diff_url":"https://github.com/fastify/fastify/pull/862.diff","patch_url":"https://github.com/fastify/fastify/pull/862.patch"},"body":"At the moment if we send a request with a not declared method, the 404 router will always return a 405 error, because of the following two lines.\r\nhttps://github.com/fastify/fastify/blob/c6a0eecf014e923d83d9cf2ac2c3616bcd930dea/fastify.js#L778-L779\r\nThe user expects a 404 instead.\r\nThis solution fixes the issue, but I think we will never return a 405 error because of https://github.com/delvedor/find-my-way/pull/72.\r\n\r\nRef: [private team discussion](https://github.com/orgs/fastify/teams/fastify/discussions/17) and https://github.com/fastify/fastify/pull/851\r\n\r\n#### Checklist\r\n\r\n- [x] run `npm run test` and `npm run benchmark`\r\n- [x] tests and/or benchmarks are included\r\n- [ ] documentation is changed or added\r\n- [x] commit message and code follows [Code of conduct](https://github.com/fastify/fastify/blob/master/CODE_OF_CONDUCT.md)\r\n"},"comment":{"url":"https://api.github.com/repos/fastify/fastify/issues/comments/376001121","html_url":"https://github.com/fastify/fastify/pull/862#issuecomment-376001121","issue_url":"https://api.github.com/repos/fastify/fastify/issues/862","id":376001121,"user":{"login":"delvedor","id":4865608,"avatar_url":"https://avatars0.githubusercontent.com/u/4865608?v=4","gravatar_id":"","url":"https://api.github.com/users/delvedor","html_url":"https://github.com/delvedor","followers_url":"https://api.github.com/users/delvedor/followers","following_url":"https://api.github.com/users/delvedor/following{/other_user}","gists_url":"https://api.github.com/users/delvedor/gists{/gist_id}","starred_url":"https://api.github.com/users/delvedor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/delvedor/subscriptions","organizations_url":"https://api.github.com/users/delvedor/orgs","repos_url":"https://api.github.com/users/delvedor/repos","events_url":"https://api.github.com/users/delvedor/events{/privacy}","received_events_url":"https://api.github.com/users/delvedor/received_events","type":"User","site_admin":false},"created_at":"2018-03-25T20:32:43Z","updated_at":"2018-03-25T20:32:43Z","author_association":"OWNER","body":"Now we return a 404 in all the cases.\r\n\r\nWith this solution if a user declares an `all` route, all the unsupported method will return a 404 error, even if the handler is declared.\r\n```js\r\nfastify.all('/', (req, reply) => {\r\n  reply.send({ hello: 'world' })\r\n})\r\n\r\nfastify.inject({\r\n  method: 'PROPFIND',\r\n  url: '/'\r\n}, (err, res) => {\r\n  console.log(res.statusCode) // 404\r\n})\r\n```"}}
{"actor":{"display_login":"delvedor"}}