You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Internal links have been changed to relative URLs. This should help with redirecting to translated pages (the URL won't have to be localized) and keeping the right version.
Anchors that point to headers that are localized will have to be changed.
This property is much like `req.url`; however, it retains the original request URL,
221
221
allowing you to rewrite `req.url` freely for internal routing purposes. For example,
222
-
the "mounting" feature of [app.use()](#app.use) will rewrite `req.url` to strip the mount point.
222
+
the "mounting" feature of [app.use()](../application/#appusepath-callback--callback) will rewrite `req.url` to strip the mount point.
223
223
224
224
```js
225
225
// GET /search?q=something
@@ -242,7 +242,7 @@ app.use('/admin', function (req, res, next) {
242
242
243
243
### req.params
244
244
245
-
This property is an object containing properties mapped to the [named route "parameters"](/en/guide/routing#route-parameters). For example, if you have the route `/user/:name`, then the "name" property is available as `req.params.name`. This object defaults to `{}`.
245
+
This property is an object containing properties mapped to the [named route "parameters"](../../guide/routing/#route-parameters). For example, if you have the route `/user/:name`, then the "name" property is available as `req.params.name`. This object defaults to `{}`.
246
246
247
247
```js
248
248
// GET /user/tj
@@ -260,7 +260,7 @@ console.dir(req.params[0]);
260
260
261
261
Named capturing groups in regular expressions behave like named route parameters. For example the group from `/^\/file\/(?<path>.*)$/` expression is available as `req.params.path`.
262
262
263
-
If you need to make changes to a key in `req.params`, use the [app.param](/en/4x/api#app.param) handler. Changes are applicable only to [parameters](/en/guide/routing#route-parameters) already defined in the route path.
263
+
If you need to make changes to a key in `req.params`, use the [app.param](../application/#appparamname-callback) handler. Changes are applicable only to [parameters](../../guide/routing/#route-parameters) already defined in the route path.
264
264
265
265
Any changes made to the `req.params` object in a middleware or route handler will be reset.
266
266
@@ -283,15 +283,15 @@ console.dir(req.path);
283
283
<Alerttype="info">
284
284
285
285
When called from a middleware, the mount point is not included in `req.path`. See
286
-
[app.use()](/en/4x/api#app.use) for more details.
286
+
[app.use()](../application/#appusepath-callback--callback) for more details.
287
287
288
288
</Alert>
289
289
290
290
### req.protocol
291
291
292
292
Contains the request protocol string: either `http` or (for TLS requests) `https`.
293
293
294
-
When the [`trust proxy` setting](#trust.proxy.options.table) does not evaluate to `false`,
294
+
When the [`trust proxy` setting](../application/#options-for-trust-proxy-setting) does not evaluate to `false`,
295
295
this property will use the value of the `X-Forwarded-Proto` header field if present.
296
296
This header can be set by the client or by the proxy.
297
297
@@ -303,7 +303,7 @@ console.dir(req.protocol);
303
303
### req.query
304
304
305
305
This property is an object containing a property for each query string parameter in the route.
306
-
When [query parser](/en/api/application/app-set#app.settings.table) is set to disabled, it is an empty object `{}`, otherwise it is the result of the configured query parser.
306
+
When [query parser](../application/#application-settings) is set to disabled, it is an empty object `{}`, otherwise it is the result of the configured query parser.
307
307
308
308
<Alerttype="warning">
309
309
@@ -314,7 +314,7 @@ may not be a function and instead a string or other user-input.
314
314
315
315
</Alert>
316
316
317
-
The value of this property can be configured with the [query parser application setting](/en/api/application/app-set#app.settings.table) to work how your application needs it. A very popular query string parser is the [`qs` module](https://www.npmjs.org/package/qs), and this is used by default. The `qs` module is very configurable with many settings, and it may be desirable to use different settings than the default to populate `req.query`:
317
+
The value of this property can be configured with the [query parser application setting](../application/#application-settings) to work how your application needs it. A very popular query string parser is the [`qs` module](https://www.npmjs.org/package/qs), and this is used by default. The `qs` module is very configurable with many settings, and it may be desirable to use different settings than the default to populate `req.query`:
318
318
319
319
```js
320
320
var qs =require('qs');
@@ -325,11 +325,11 @@ app.set('query parser', function (str) {
325
325
});
326
326
```
327
327
328
-
Check out the [query parser application setting](/en/api/application/app-set#app.settings.table) documentation for other customization options.
328
+
Check out the [query parser application setting](../application/#application-settings) documentation for other customization options.
329
329
330
330
### req.res
331
331
332
-
This property holds a reference to the <ahref="#res">response object</a>
332
+
This property holds a reference to the [response object](../response)
333
333
that relates to this request object.
334
334
335
335
### req.route
@@ -407,7 +407,7 @@ console.dir(req.subdomains);
407
407
408
408
The application property `subdomain offset`, which defaults to 2, is used for determining the
409
409
beginning of the subdomain segments. To change this behavior, change its value
410
-
using [app.set](/en/4x/api#app.set).
410
+
using [app.set](../application/#appsetname-value).
The following are some examples of JSONP responses using the same code:
408
408
@@ -458,7 +458,7 @@ res.location('back');
458
458
A `path` value of "back" has a special meaning, it refers to the URL specified in the `Referer` header of the request. If the `Referer` header was not specified, it refers to "/".
459
459
460
460
See also [Security best practices: Prevent open redirect
The `view` argument is a string that is the file path of the view file to render. This can be an absolute path, or a path relative to the `views` setting. If the path does not contain a file extension, then the `view engine` setting determines the file extension. If the path does contain a file extension, then Express will load the module for the specified template engine (via `require()`) and render it using the loaded module's `__express` function.
546
546
547
-
For more information, see [Using template engines with Express](/en/guide/using-template-engines).
547
+
For more information, see [Using template engines with Express](../../guide/using-template-engines).
Copy file name to clipboardExpand all lines: src/content/api/4x/api/router/index.mdx
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,9 +10,9 @@ as a "mini-application," capable only of performing middleware and routing
10
10
functions. Every Express application has a built-in app router.
11
11
12
12
A router behaves like middleware itself, so you can use it as an argument to
13
-
[app.use()](/en/4x/api/application#appusepath-callback--callback) or as the argument to another router's [use()](#routerusepath-function--function) method.
13
+
[app.use()](../application#appusepath-callback--callback) or as the argument to another router's [use()](#routerusepath-function--function) method.
14
14
15
-
The top-level `express` object has a [Router()](/en/4x/api/express#expressrouteroptions) method that creates a new `router` object.
15
+
The top-level `express` object has a [Router()](../express#expressrouteroptions) method that creates a new `router` object.
16
16
17
17
Once you've created a router object, you can add middleware and HTTP method routes (such as `get`, `put`, `post`,
18
18
and so on) to it just like an application. For example:
@@ -306,8 +306,8 @@ belong to the route to which they were added.
306
306
307
307
Uses the specified middleware function or functions, with optional mount path `path`, that defaults to "/".
308
308
309
-
This method is similar to [app.use()](/en/4x/api/application#appusepath-callback--callback). A simple example and use case is described below.
310
-
See [app.use()](/en/4x/api/application#appusepath-callback--callback) for more information.
309
+
This method is similar to [app.use()](../application#appusepath-callback--callback). A simple example and use case is described below.
310
+
See [app.use()](../application#appusepath-callback--callback) for more information.
311
311
312
312
Middleware is like a plumbing pipe: requests start at the first middleware function defined
313
313
and work their way "down" the middleware stack processing for each path they match.
0 commit comments