From de1828c933f787aac1cb90c6a6833f09a5efe5a9 Mon Sep 17 00:00:00 2001 From: cesarvspr Date: Sat, 22 Oct 2022 16:45:27 -0400 Subject: [PATCH 1/4] docs: #4025 --- docs/Reference/Reply.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/Reference/Reply.md b/docs/Reference/Reply.md index c669790927..77fcd3605e 100644 --- a/docs/Reference/Reply.md +++ b/docs/Reference/Reply.md @@ -311,6 +311,11 @@ reply.code(303).redirect(302, '/home') Invokes the custom not found handler. Note that it will only call `preHandler` hook specified in [`setNotFoundHandler`](./Server.md#set-not-found-handler). + +> Note: Be aware that some config properties from the request object will be undefined inside the custom not found handler. E.g: +> request.routerPath, routerMethod and context.config. +> This method design goal is to allow calling the common not found route. If you want to return a per-route customized 404 response, you can just do it in the response itself. + ```js reply.callNotFound() ``` From bc9cdcaf323bec5a12b14719b338cbf2f02ebba4 Mon Sep 17 00:00:00 2001 From: cesarvspr Date: Sat, 22 Oct 2022 18:11:28 -0400 Subject: [PATCH 2/4] chore: docs --- docs/Reference/Reply.md | 4 ---- docs/Reference/Server.md | 4 ++++ 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/Reference/Reply.md b/docs/Reference/Reply.md index 77fcd3605e..3703757e04 100644 --- a/docs/Reference/Reply.md +++ b/docs/Reference/Reply.md @@ -312,10 +312,6 @@ Invokes the custom not found handler. Note that it will only call `preHandler` hook specified in [`setNotFoundHandler`](./Server.md#set-not-found-handler). -> Note: Be aware that some config properties from the request object will be undefined inside the custom not found handler. E.g: -> request.routerPath, routerMethod and context.config. -> This method design goal is to allow calling the common not found route. If you want to return a per-route customized 404 response, you can just do it in the response itself. - ```js reply.callNotFound() ``` diff --git a/docs/Reference/Server.md b/docs/Reference/Server.md index 77e7805b41..890566946d 100644 --- a/docs/Reference/Server.md +++ b/docs/Reference/Server.md @@ -1426,6 +1426,10 @@ plugins are registered. If you would like to augment the behavior of the default arguments `fastify.setNotFoundHandler()` within the context of these registered plugins. +> Note: Be aware that some config properties from the request object will be undefined inside the custom not found handler. E.g: +> request.routerPath, routerMethod and context.config. +> This method design goal is to allow calling the common not found route. If you want to return a per-route customized 404 response, you can just do it in the response itself. + #### setErrorHandler From b73bf0895c9a69d066457f1c965415f6e12e6673 Mon Sep 17 00:00:00 2001 From: cesarvspr Date: Sat, 22 Oct 2022 18:21:40 -0400 Subject: [PATCH 3/4] fix: undo not necessary change --- docs/Reference/Reply.md | 1 - docs/Reference/Server.md | 7 +++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/Reference/Reply.md b/docs/Reference/Reply.md index 3703757e04..c669790927 100644 --- a/docs/Reference/Reply.md +++ b/docs/Reference/Reply.md @@ -311,7 +311,6 @@ reply.code(303).redirect(302, '/home') Invokes the custom not found handler. Note that it will only call `preHandler` hook specified in [`setNotFoundHandler`](./Server.md#set-not-found-handler). - ```js reply.callNotFound() ``` diff --git a/docs/Reference/Server.md b/docs/Reference/Server.md index 890566946d..abe0be625d 100644 --- a/docs/Reference/Server.md +++ b/docs/Reference/Server.md @@ -1426,9 +1426,12 @@ plugins are registered. If you would like to augment the behavior of the default arguments `fastify.setNotFoundHandler()` within the context of these registered plugins. -> Note: Be aware that some config properties from the request object will be undefined inside the custom not found handler. E.g: +> Note: Be aware that some config properties from the request object will be +> undefined inside the custom not found handler. E.g: > request.routerPath, routerMethod and context.config. -> This method design goal is to allow calling the common not found route. If you want to return a per-route customized 404 response, you can just do it in the response itself. +> This method design goal is to allow calling the common not found route. If +> you want to return a per-route customized 404 response, you can just do it in +> the response itself. #### setErrorHandler From 403b5d06842dee8ed7170745e2b1a0961dcb51bb Mon Sep 17 00:00:00 2001 From: "Cesar V. Sampaio" <37849741+cesarvspr@users.noreply.github.com> Date: Sun, 23 Oct 2022 07:08:09 -0400 Subject: [PATCH 4/4] Update docs/Reference/Server.md Co-authored-by: Frazer Smith --- docs/Reference/Server.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/Reference/Server.md b/docs/Reference/Server.md index abe0be625d..1af2057c8e 100644 --- a/docs/Reference/Server.md +++ b/docs/Reference/Server.md @@ -1426,11 +1426,11 @@ plugins are registered. If you would like to augment the behavior of the default arguments `fastify.setNotFoundHandler()` within the context of these registered plugins. -> Note: Be aware that some config properties from the request object will be +> Note: Some config properties from the request object will be > undefined inside the custom not found handler. E.g: -> request.routerPath, routerMethod and context.config. -> This method design goal is to allow calling the common not found route. If -> you want to return a per-route customized 404 response, you can just do it in +> `request.routerPath`, `routerMethod` and `context.config`. +> This method design goal is to allow calling the common not found route. +> To return a per-route customized 404 response, you can do it in > the response itself. #### setErrorHandler