From 350f00b6bf508b40c1f6bb5fa1a9e81b1b09ef3a Mon Sep 17 00:00:00 2001 From: Glen Keane Date: Fri, 28 Feb 2020 11:38:34 +0000 Subject: [PATCH] docs: Clarify reply.redirect status code docs (#2121) fixes #1592 The documentation is much more specific about calling reply.redirect() where .code() has and has not been called. --- docs/Reply.md | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/docs/Reply.md b/docs/Reply.md index d68c12b9e7..7fd64d3e0d 100644 --- a/docs/Reply.md +++ b/docs/Reply.md @@ -122,12 +122,29 @@ reply.getHeader('x-foo') // undefined Returns a boolean indicating if the specified header has been set. -### .redirect(dest) +### .redirect([code ,] dest) Redirects a request to the specified url, the status code is optional, default to `302` (if status code is not already set by calling `code`). + +Example (no `reply.code()` call) sets status code to `302` and redirects to `/home` ```js reply.redirect('/home') ``` +Example (no `reply.code()` call) sets status code to `303` and redirects to `/home` +```js +reply.redirect(303, '/home') +``` + +Example (`reply.code()` call) sets status code to `303` and redirects to `/home` +```js +reply.code(303).redirect('/home') +``` + +Example (`reply.code()` call) sets status code to `302` and redirects to `/home` +```js +reply.code(303).redirect(302, '/home') +``` + ### .callNotFound() Invokes the custom not found handler.