Skip to content

Commit

Permalink
doc: improve setDefaultRoute documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
RafaelGSS committed Dec 23, 2022
1 parent 4bde0e0 commit 04a743a
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions docs/Reference/Server.md
Original file line number Diff line number Diff line change
Expand Up @@ -1024,13 +1024,20 @@ const defaultRoute = fastify.getDefaultRoute()
<a id="setDefaultRoute"></a>

**Note**: The default 404 handler, or one set using `setNotFoundHandler`, will
never trigger if the default route is overridden. This sets the handler for the
never trigger if the default route is overridden. This sets the handler for the
Fastify application, not just the current instance context. Use
[setNotFoundHandler](#setnotfoundhandler) if you want to customize 404 handling
instead. Method to set the `defaultRoute` for the server:
instead.

This method set the `defaultRoute` for the server. Note that, its purpose is
to interact with the underlying raw requests. Unlike other Fastify handlers, the
arguments received are from type [RawRequest](./TypeScript.md#rawrequest) and
[RawReply](./TypeScript.md#rawreply) respectively.

```js
const defaultRoute = function (req, res) {
// req = RawRequest
// res = RawReply
res.end('hello world')
}

Expand Down

0 comments on commit 04a743a

Please sign in to comment.