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
Das Objekt `app.router`, das in Express 4 entfernt wurde, ist in Express 5 wieder verfügbar. In der neuen Version fungiert dieses Objekt nur als Referenz zum Express-Basisrouter – im Gegensatz zu Express 3, wo die Anwendung dieses Objekt explizit laden musste.
514
515
515
-
<h3id="req.body">req.body</h3>
516
+
<h3id="req.body">req.body</h3>
516
517
517
518
The `req.body` property returns `undefined` when the body has not been parsed. In Express 4, it returns `{}` by default.
518
519
519
520
<h3id="req.host">req.host</h3>
520
521
521
522
In Express 4 übergab die Funktion `req.host` nicht ordnungsgemäß eine eventuell vorhandene Portnummer. In Express 5 wird die Portnummer beibehalten.
522
523
524
+
<h3id="req.params">req.params</h3>
525
+
526
+
The `req.params` object now has a **null prototype** when using string paths. However, if the path is defined with a regular expression, `req.params` remains a standard object with a normal prototype. Additionally, there are two important behavioral changes:
527
+
528
+
**Wildcard parameters are now arrays:**
529
+
530
+
Wildcards (e.g., `/*splat`) capture path segments as an array instead of a single string.
In Express 4, unmatched wildcards were empty strings (`''`) and optional `:` parameters (using `?`) had a key with value `undefined`. In Express 5, unmatched parameters are completely omitted from `req.params`.
543
+
544
+
```js
545
+
// v4: unmatched wildcard is empty string
546
+
app.get('/*', (req, res) => {
547
+
// GET /
548
+
console.dir(req.params)
549
+
// => { '0': '' }
550
+
})
551
+
552
+
// v4: unmatched optional param is undefined
553
+
app.get('/:file.:ext?', (req, res) => {
554
+
// GET /image
555
+
console.dir(req.params)
556
+
// => { file: 'image', ext: undefined }
557
+
})
558
+
559
+
// v5: unmatched optional param is omitted
560
+
app.get('/:file{.:ext}', (req, res) => {
561
+
// GET /image
562
+
console.dir(req.params)
563
+
// => [Object: null prototype] { file: 'image' }
564
+
})
565
+
```
566
+
523
567
<h3id="req.query">req.query</h3>
524
568
525
569
The `req.query` property is no longer a writable property and is instead a getter. The default query parser has been changed from "extended" to "simple".
El objeto `app.router`, que se ha eliminado en Express 4, ha vuelto en Express 5. En la nueva versión, este objeto es sólo una referencia al direccionador de Express base, a diferencia de en Express 3, donde una aplicación debía cargarlo explícitamente.
514
515
515
-
<h3id="req.body">req.body</h3>
516
+
<h3id="req.body">req.body</h3>
516
517
517
518
The `req.body` property returns `undefined` when the body has not been parsed. In Express 4, it returns `{}` by default.
518
519
519
520
<h3id="req.host">req.host</h3>
520
521
521
522
En Express 4, la función `req.host` fragmentaba incorrectamente el número de puerto si estaba presente. In Express 5, the port number is maintained.
522
523
524
+
<h3id="req.params">req.params</h3>
525
+
526
+
The `req.params` object now has a **null prototype** when using string paths. However, if the path is defined with a regular expression, `req.params` remains a standard object with a normal prototype. Additionally, there are two important behavioral changes:
527
+
528
+
**Wildcard parameters are now arrays:**
529
+
530
+
Wildcards (e.g., `/*splat`) capture path segments as an array instead of a single string.
In Express 4, unmatched wildcards were empty strings (`''`) and optional `:` parameters (using `?`) had a key with value `undefined`. In Express 5, unmatched parameters are completely omitted from `req.params`.
543
+
544
+
```js
545
+
// v4: unmatched wildcard is empty string
546
+
app.get('/*', (req, res) => {
547
+
// GET /
548
+
console.dir(req.params)
549
+
// => { '0': '' }
550
+
})
551
+
552
+
// v4: unmatched optional param is undefined
553
+
app.get('/:file.:ext?', (req, res) => {
554
+
// GET /image
555
+
console.dir(req.params)
556
+
// => { file: 'image', ext: undefined }
557
+
})
558
+
559
+
// v5: unmatched optional param is omitted
560
+
app.get('/:file{.:ext}', (req, res) => {
561
+
// GET /image
562
+
console.dir(req.params)
563
+
// => [Object: null prototype] { file: 'image' }
564
+
})
565
+
```
566
+
523
567
<h3id="req.query">req.query</h3>
524
568
525
569
The `req.query` property is no longer a writable property and is instead a getter. The default query parser has been changed from "extended" to "simple".
L'objet `app.router`, qui a été supprimé dans Express 4, est revenu dans Express 5. Dans la version, cet objet
568
569
n'est qu'une référence dans le routeur Express de base, contrairement à Express 3, où une application devait le charger explicitement.
569
570
570
-
<h3id="req.body">req.body</h3>
571
+
<h3id="req.body">req.body</h3>
571
572
572
573
The `req.body` property returns `undefined` when the body has not been parsed. In Express 4, it returns `{}` by default.
573
574
@@ -576,6 +577,49 @@ The `req.body` property returns `undefined` when the body has not been parsed. I
576
577
Dans Express 4, la `req.host` retirait de
577
578
manière incorrecte le numéro de port s'il était présent. Dans Express 5, ce numéro de port est conservé.
578
579
580
+
<h3id="req.params">req.params</h3>
581
+
582
+
The `req.params` object now has a **null prototype** when using string paths. However, if the path is defined with a regular expression, `req.params` remains a standard object with a normal prototype. Additionally, there are two important behavioral changes:
583
+
584
+
**Wildcard parameters are now arrays:**
585
+
586
+
Wildcards (e.g., `/*splat`) capture path segments as an array instead of a single string.
In Express 4, unmatched wildcards were empty strings (`''`) and optional `:` parameters (using `?`) had a key with value `undefined`. In Express 5, unmatched parameters are completely omitted from `req.params`.
599
+
600
+
```js
601
+
// v4: unmatched wildcard is empty string
602
+
app.get('/*', (req, res) => {
603
+
// GET /
604
+
console.dir(req.params)
605
+
// => { '0': '' }
606
+
})
607
+
608
+
// v4: unmatched optional param is undefined
609
+
app.get('/:file.:ext?', (req, res) => {
610
+
// GET /image
611
+
console.dir(req.params)
612
+
// => { file: 'image', ext: undefined }
613
+
})
614
+
615
+
// v5: unmatched optional param is omitted
616
+
app.get('/:file{.:ext}', (req, res) => {
617
+
// GET /image
618
+
console.dir(req.params)
619
+
// => [Object: null prototype] { file: 'image' }
620
+
})
621
+
```
622
+
579
623
<h3id="req.query">req.query</h3>
580
624
581
625
The `req.query` property is no longer a writable property and is instead a getter. The default query parser has been changed from "extended" to "simple".
Copy file name to clipboardExpand all lines: fr/guide/routing.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,7 +13,7 @@ _Routage_ fait référence à la définition de points finaux d'application (URI
13
13
Pour une introduction au routage, voir [Basic routing](/{{ page.lang }}/starter/basic-routing.html).
14
14
15
15
Vous définissez le routage à l’aide des méthodes de l’objet app d’Express correspondant aux méthodes HTTP :
16
-
par exemple, `app.get()` pour les requêtes GET et \`app.post pour les requêtes POST. Pour la liste complète,
16
+
par exemple, `app.get()` pour les requêtes GET et `app.post` pour les requêtes POST. Pour la liste complète,
17
17
voir [app.METHOD](/{{ page.lang }}/5x/api.html#app.METHOD). Vous pouvez également utiliser [app.all()](/{{ page.lang }}/5x/api.html#app.all) pour gérer toutes les méthodes HTTP et [app.use()](/{{ page.lang }}/5x/api.html#app.use) spécifier le middleware comme fonction de rappel (Voir [Utilisation du middleware](/{{ page.lang }}/guide/using-middleware.html) pour plus de détails).
18
18
19
19
Ces méthodes de routage spécifient une fonction de rappel (parfois "appelée fonction de gestion") qui est appelée lorsque l'application reçoit une requête correspondant à la route (point de terminaison) et à la méthode HTTP spécifiées. Autrement dit, l'application "écoute" les requêtes qui correspondent à la ou aux routes et à la ou aux méthodes spécifiées, et lorsqu'une correspondance est détectée, elle appelle la fonction de rappel définie.
L'oggetto `app.router`, che era stato rimosso in Express 4, è ritornato in Express 5. Nella nuova versione, questo oggetto è solo un riferimento al router Express di base, diversamente da Express 3, in cui un'applicazione aveva il compito esplicito di caricarlo.
514
515
515
-
<h3id="req.body">req.body</h3>
516
+
<h3id="req.body">req.body</h3>
516
517
517
518
The `req.body` property returns `undefined` when the body has not been parsed. In Express 4, it returns `{}` by default.
518
519
519
520
<h3id="req.host">req.host</h3>
520
521
521
522
In Express 4, la funzione `req.host` andava a rimuovere in modo non corretto il numero porta nel caso fosse stato presente. In Express 5 il numero porta viene conservato.
522
523
524
+
<h3id="req.params">req.params</h3>
525
+
526
+
The `req.params` object now has a **null prototype** when using string paths. However, if the path is defined with a regular expression, `req.params` remains a standard object with a normal prototype. Additionally, there are two important behavioral changes:
527
+
528
+
**Wildcard parameters are now arrays:**
529
+
530
+
Wildcards (e.g., `/*splat`) capture path segments as an array instead of a single string.
In Express 4, unmatched wildcards were empty strings (`''`) and optional `:` parameters (using `?`) had a key with value `undefined`. In Express 5, unmatched parameters are completely omitted from `req.params`.
543
+
544
+
```js
545
+
// v4: unmatched wildcard is empty string
546
+
app.get('/*', (req, res) => {
547
+
// GET /
548
+
console.dir(req.params)
549
+
// => { '0': '' }
550
+
})
551
+
552
+
// v4: unmatched optional param is undefined
553
+
app.get('/:file.:ext?', (req, res) => {
554
+
// GET /image
555
+
console.dir(req.params)
556
+
// => { file: 'image', ext: undefined }
557
+
})
558
+
559
+
// v5: unmatched optional param is omitted
560
+
app.get('/:file{.:ext}', (req, res) => {
561
+
// GET /image
562
+
console.dir(req.params)
563
+
// => [Object: null prototype] { file: 'image' }
564
+
})
565
+
```
566
+
523
567
<h3id="req.query">req.query</h3>
524
568
525
569
The `req.query` property is no longer a writable property and is instead a getter. The default query parser has been changed from "extended" to "simple".
`app.router` オブジェクトは、Express 4 で削除されましたが、Express 5 で復帰しました。アプリケーションが明示的にロードする必要があった Express 3 とは異なり、新しいバージョンでは、このオブジェクトは基本の Express ルーターの単なる参照です。 In the new version, this object is a just a reference to the base Express router, unlike in Express 3, where an app had to explicitly load it.
514
515
515
-
<h3id="req.body">req.body</h3>
516
+
<h3id="req.body">req.body</h3>
516
517
517
518
The `req.body` property returns `undefined` when the body has not been parsed. In Express 4, it returns `{}` by default.
518
519
519
520
<h3id="req.host">req.host</h3>
520
521
521
522
Express 4 では、`req.host` 関数は、ポート番号が存在する場合に、ポート番号を誤って削除していました。Express 5 では、ポート番号は維持されます。 In Express 5, the port number is maintained.
522
523
524
+
<h3id="req.params">req.params</h3>
525
+
526
+
The `req.params` object now has a **null prototype** when using string paths. However, if the path is defined with a regular expression, `req.params` remains a standard object with a normal prototype. Additionally, there are two important behavioral changes:
527
+
528
+
**Wildcard parameters are now arrays:**
529
+
530
+
Wildcards (e.g., `/*splat`) capture path segments as an array instead of a single string.
In Express 4, unmatched wildcards were empty strings (`''`) and optional `:` parameters (using `?`) had a key with value `undefined`. In Express 5, unmatched parameters are completely omitted from `req.params`.
543
+
544
+
```js
545
+
// v4: unmatched wildcard is empty string
546
+
app.get('/*', (req, res) => {
547
+
// GET /
548
+
console.dir(req.params)
549
+
// => { '0': '' }
550
+
})
551
+
552
+
// v4: unmatched optional param is undefined
553
+
app.get('/:file.:ext?', (req, res) => {
554
+
// GET /image
555
+
console.dir(req.params)
556
+
// => { file: 'image', ext: undefined }
557
+
})
558
+
559
+
// v5: unmatched optional param is omitted
560
+
app.get('/:file{.:ext}', (req, res) => {
561
+
// GET /image
562
+
console.dir(req.params)
563
+
// => [Object: null prototype] { file: 'image' }
564
+
})
565
+
```
566
+
523
567
<h3id="req.query">req.query</h3>
524
568
525
569
The `req.query` property is no longer a writable property and is instead a getter. The default query parser has been changed from "extended" to "simple".
0 commit comments