Skip to content

Commit

Permalink
docs: Clarify reply.redirect status code docs (#2121)
Browse files Browse the repository at this point in the history
fixes #1592

The documentation is much more specific about
calling reply.redirect() where .code() has and has
not been called.
  • Loading branch information
GlenTiki committed Feb 28, 2020
1 parent a378dd5 commit 350f00b
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion docs/Reply.md
Expand Up @@ -122,12 +122,29 @@ reply.getHeader('x-foo') // undefined
Returns a boolean indicating if the specified header has been set.

<a name="redirect"></a>
### .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')
```

<a name="call-not-found"></a>
### .callNotFound()
Invokes the custom not found handler.
Expand Down

0 comments on commit 350f00b

Please sign in to comment.