From 7e2d60bea0dd811872b99ac5239c0b4d6ce22605 Mon Sep 17 00:00:00 2001 From: MaoShizhong <122839503+MaoShizhong@users.noreply.github.com> Date: Fri, 17 May 2024 15:28:41 +0100 Subject: [PATCH] Clarify inheritance behaviour of route params in .params (#1515) Current documentation specifies router param callbacks are not inherited by mounted apps or routers, but does not also specify they do not inherit from parent routers either. --- _includes/api/en/4x/app-param.md | 2 +- _includes/api/en/4x/router-param.md | 2 +- _includes/api/en/5x/app-param.md | 2 +- _includes/api/en/5x/router-param.md | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/_includes/api/en/4x/app-param.md b/_includes/api/en/4x/app-param.md index 0984722e10..2b0d8bf2aa 100644 --- a/_includes/api/en/4x/app-param.md +++ b/_includes/api/en/4x/app-param.md @@ -22,7 +22,7 @@ app.param('user', function (req, res, next, id) { }) ``` -Param callback functions are local to the router on which they are defined. They are not inherited by mounted apps or routers. Hence, param callbacks defined on `app` will be triggered only by route parameters defined on `app` routes. +Param callback functions are local to the router on which they are defined. They are not inherited by mounted apps or routers, nor are they triggered for route parameters inherited from parent routers. Hence, param callbacks defined on `app` will be triggered only by route parameters defined on `app` routes. All param callbacks will be called before any handler of any route in which the param occurs, and they will each be called only once in a request-response cycle, even if the parameter is matched in multiple routes, as shown in the following examples. diff --git a/_includes/api/en/4x/router-param.md b/_includes/api/en/4x/router-param.md index 3fe0083bd9..20b35d1afe 100644 --- a/_includes/api/en/4x/router-param.md +++ b/_includes/api/en/4x/router-param.md @@ -32,7 +32,7 @@ router.param('user', function (req, res, next, id) { }) ``` -Param callback functions are local to the router on which they are defined. They are not inherited by mounted apps or routers. Hence, param callbacks defined on `router` will be triggered only by route parameters defined on `router` routes. +Param callback functions are local to the router on which they are defined. They are not inherited by mounted apps or routers, nor are they triggered for route parameters inherited from parent routers. Hence, param callbacks defined on `router` will be triggered only by route parameters defined on `router` routes. A param callback will be called only once in a request-response cycle, even if the parameter is matched in multiple routes, as shown in the following examples. diff --git a/_includes/api/en/5x/app-param.md b/_includes/api/en/5x/app-param.md index dd8b1ad970..a1e064add2 100644 --- a/_includes/api/en/5x/app-param.md +++ b/_includes/api/en/5x/app-param.md @@ -22,7 +22,7 @@ app.param('user', (req, res, next, id) => { }) ``` -Param callback functions are local to the router on which they are defined. They are not inherited by mounted apps or routers. Hence, param callbacks defined on `app` will be triggered only by route parameters defined on `app` routes. +Param callback functions are local to the router on which they are defined. They are not inherited by mounted apps or routers, nor are they triggered for route parameters inherited from parent routers. Hence, param callbacks defined on `app` will be triggered only by route parameters defined on `app` routes. All param callbacks will be called before any handler of any route in which the param occurs, and they will each be called only once in a request-response cycle, even if the parameter is matched in multiple routes, as shown in the following examples. diff --git a/_includes/api/en/5x/router-param.md b/_includes/api/en/5x/router-param.md index aaa1c6d610..f2b11d8946 100644 --- a/_includes/api/en/5x/router-param.md +++ b/_includes/api/en/5x/router-param.md @@ -32,7 +32,7 @@ router.param('user', (req, res, next, id) => { }) ``` -Param callback functions are local to the router on which they are defined. They are not inherited by mounted apps or routers. Hence, param callbacks defined on `router` will be triggered only by route parameters defined on `router` routes. +Param callback functions are local to the router on which they are defined. They are not inherited by mounted apps or routers, nor are they triggered for route parameters inherited from parent routers. Hence, param callbacks defined on `router` will be triggered only by route parameters defined on `router` routes. A param callback will be called only once in a request-response cycle, even if the parameter is matched in multiple routes, as shown in the following examples.