Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lib: deprecate the default route and improve its documentation #4480

Merged
merged 2 commits into from Dec 27, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 9 additions & 2 deletions docs/Reference/Server.md
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would be even more specific:
let's deprecate this and remove in the next major.z

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
RafaelGSS marked this conversation as resolved.
Show resolved Hide resolved
to interact with the underlying raw requests. Unlike other Fastify handlers, the
arguments received are from type [RawRequest](./TypeScript.md#rawrequest) and
RafaelGSS marked this conversation as resolved.
Show resolved Hide resolved
[RawReply](./TypeScript.md#rawreply) respectively.

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

Expand Down