Renvoie la méthode et le corps de la requête. Accepte JSON, le texte brut, les données de formulaire simples et les données binaires.
Détails
Exemples de requêtes
POST · JSON
curl 'http://localhost:3000/v1/echo' \
-H 'Content-Type: application/json' \
--data-binary '{"name":"Bob"}'
POST · Texte brut
curl 'http://localhost:3000/v1/echo' \
-H 'Content-Type: text/plain' \
--data-binary 'Hello!'
POST · Formulaire
curl 'http://localhost:3000/v1/echo' \
--data-urlencode 'name=Bob' \
--data-urlencode 'age=42'
POST · Fichier binaire
curl 'http://localhost:3000/v1/echo' \
-H 'Content-Type: application/octet-stream' \
--data-binary '@./file.bin'
Réponses
200 OK
La méthode et le corps de la requête après analyse. Cet exemple est une requête GET sans corps.
Exemple · text/plain
GET
null
Exemple · application/json
{
"method": "GET",
"body": null
}
Schéma · object
| Champ | Type | Description |
|---|
methodobligatoire | string | La méthode HTTP de la requête. |
|---|
bodyobligatoire | object | array | string | number | boolean | null | Une valeur JSON, une chaîne, des champs de formulaire ou un corps binaire { encoding: 'base64', sizeBytes: number, data: string }. null si aucun corps n’est fourni. |
|---|
body · objet binaire
| Champ | Type | Description |
|---|
encodingobligatoire | string | Toujours "base64". |
|---|
sizeBytesobligatoire | integer | Nombre d’octets d’origine. |
|---|
dataobligatoire | string | Contenu encodé en Base64. |
|---|
400 Bad Request
Valeur de format invalide, par exemple ?format=xml. Cette erreur est toujours renvoyée en texte brut.
Exemple · text/plain
Unsupported format: xml
Valid values: text, json
Exemple · text/plain
Unsupported format: xml
Valid values: text, json
413 Payload Too Large
Le corps dépasse 102 400 octets (100 Kio).
Exemple · text/plain
Request body exceeds the size limit of 100 KiB
Exemple · application/json
{
"error": "Request body exceeds the size limit of 100 KiB",
"limitBytes": 102400
}
Schéma · object
| Champ | Type | Description |
|---|
errorobligatoire | string | Description de l’erreur. |
|---|
limitBytesobligatoire | integer | Taille maximale du corps en octets. Valeur: 102400. |
|---|
415 Unsupported Media Type
Content-Type non pris en charge ou absent pour un corps non vide.
Exemple · text/plain
Unsupported Content-Type. Supported: application/json, text/plain, application/x-www-form-urlencoded, application/octet-stream
Exemple · application/json
{
"error": "Unsupported Content-Type. Supported: application/json, text/plain, application/x-www-form-urlencoded, application/octet-stream"
}
Schéma · object
| Champ | Type | Description |
|---|
errorobligatoire | string | Description de l’erreur. |
|---|
Un JSON invalide renvoie également 400. Les erreurs de syntaxe et d’encodage du parseur utilisent actuellement la réponse HTML par défaut d’Express, quel que soit le format de sortie choisi.