From 6ad5417a664d7bd53ab0707b17db2dba1371184e Mon Sep 17 00:00:00 2001 From: pancho horrillo Date: Tue, 28 May 2019 12:57:05 +0200 Subject: [PATCH] spec: resolve a bunch of TODOs and add some tweaks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: César Gallego Rodríguez --- spec/README.md | 89 +++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 81 insertions(+), 8 deletions(-) diff --git a/spec/README.md b/spec/README.md index 33a64c2..6996198 100644 --- a/spec/README.md +++ b/spec/README.md @@ -180,8 +180,24 @@ Returns JSON data about the current routes. * **Method**: `GET` * **Success Responses**: * **Code**: `200 OK`
- **Content**: TODO -* **Sample Call**: TODO + **Content**:
+ ``` + [ + { + "method": "GET", + "url_pattern": "/hello", + "entrypoint": null, + "command": "echo Hello World | response /body" + }, + { + "method": "POST", + "url_pattern": "/bye", + "entrypoint": null, + "command": "echo Bye World | response /body" + } + ] + ``` +* **Sample Call**: `$ curl $KAPOW_URL/routes` * **Notes**: Currently all routes are returned; in the future, a filter may be accepted. @@ -217,13 +233,35 @@ Accepts JSON data that defines a new route to be appended to the current routes. * **Error Responses**: * **Code**: `400 Malformed JSON` * **Code**: `400 Invalid Data Type` + * **Code**: `400 Invalid Route Spec` * **Code**: `400 Missing Mandatory Field`
**Header**: `Content-Type: application/json`
- **Content**: `{ "mandatory_fields": ["field1", "field2", "and so on"] }` -* **Sample Call**: TODO + **Content**: + ``` + { + "missing_mandatory_fields": [ + "url_pattern", + "command" + ] + } + ``` +* **Sample Call**: + ``` + $ curl -X POST --data-binary @- $KAPOW_URL/routes < **Header**: `Content-Type: application/json`
- **Content**: `{ "mandatory_fields": ["field1", "field2", "and so on"] }` + **Content**: + ``` + { + "missing_mandatory_fields": [ + "url_pattern", + "command" + ] + } + ``` * **Code**: `400 Invalid Index Type` -* **Sample Call**: TODO + * **Code**: `400 Index Already in Use` + * **Code**: `404 Invalid Index` + * **Code**: `404 Invalid Route Spec` +* **Sample Call**: + ``` + $ curl -X PUT --data-binary @- $KAPOW_URL/routes < - **Content**: TODO + **Content**: + ``` + { + "method": "GET", + "url_pattern": "/hello", + "entrypoint": null, + "command": "echo Hello World | response /body", + "index": 0 + } + ``` * **Error Responses**: * **Code**: `404 Not Found` -* **Sample Call**: TODO +* **Sample Call**: + ``` + $ curl -X DELETE $KAPOW_URL/routes/ROUTE_1f186c92_f906_4506_9788_a1f541b11d0f + ``` * **Notes**: