From 79d7e3be044be4d65f89387009118714c4853018 Mon Sep 17 00:00:00 2001 From: pancho horrillo Date: Mon, 20 May 2019 15:20:25 +0200 Subject: [PATCH] Document /routes get and append MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Roberto Abdelkader Martínez Pérez --- spec/README.md | 166 ++++++++++++++++++++++++++++++++----------------- 1 file changed, 109 insertions(+), 57 deletions(-) diff --git a/spec/README.md b/spec/README.md index e7a9ef8..7f24bf4 100644 --- a/spec/README.md +++ b/spec/README.md @@ -118,78 +118,130 @@ respond to an external event (e.g. an incomming HTTP request). Returns JSON data about the current routes. -##### URL -##### Method -##### URL Params -##### Data Params -##### Success Response -##### Error Response -##### Sample Call -##### Notes +* **URL** -#### Append a new route -##### URL -##### Method -##### URL Params -##### Data Params -##### Success Response -##### Error Response -##### Sample Call -##### Notes + /routes + +* **Method** + + GET + +* **Success Response** + + * **Code**: 200
+ **Content**: `{ TODO: maybe list of objects }` + +* **Sample Call** + + TODO + +* **Notes** + + Currently all routes are returned; in the future, a filter may be accepted. + +#### Append route + + Accepts JSON data that defines a new route to be appended to the current routes. + +* **URL** + + /routes + +* **Method** + + POST + +* **Headers** + + * **Content-Type**: application/json + +* **Data Params** + + * **Content**: + ```json + { + "method": "GET", + "url_pattern": "/hello", + "entrypoint": null, + "command": "echo Hello World | response /body" + } + ``` + +* **Success Response** + + * **Code**: `200 OK`
+ **Header**: `Content-Type: application/json`
+ **Content**: `"ROUTE_8ed01c48_bf23_455a_8186_a1df7ab09e48"` + +* **Error Response** + + * **Code**: `400 Bad Request`
+ **Header**: `Content-Type: application/json`
+ **Content**: `{ "error": "Malformed JSON." }` + + * **Code**: `422 Unprocessable Entity`
+ **Header**: `Content-Type: application/json`
+ **Content**: `{ "error": "Mandatory field(s) not provided." }` + +* **Sample Call** +TODO + +* **Notes** +TODEL if NIL #### Insert a route -##### URL -##### Method -##### URL Params -##### Data Params -##### Success Response -##### Error Response -##### Sample Call -##### Notes +* **URL** +* **Method** +* **URL Params** +* **Data Params** +* **Success Response** +* **Error Response** +* **Sample Call** +* **Notes** #### Delete a route -##### URL -##### Method -##### URL Params -##### Data Params -##### Success Response -##### Error Response -##### Sample Call -##### Notes +* **URL** +* **Method** +* **URL Params** +* **Data Params** +* **Success Response** +* **Error Response** +* **Sample Call** +* **Notes** ### Handlers #### Get the value for a handler key -##### URL -##### Method -##### URL Params -##### Data Params -##### Success Response -##### Error Response -##### Sample Call -##### Notes +* **URL** +* **Method** +* **URL Params** +* **Data Params** +* **Success Response** +* **Error Response** +* **Sample Call** +* **Notes** #### Overwrite the value for a handler key -##### URL -##### Method +* **URL** +* **Method** POST -##### URL Params -##### Data Params -##### Success Response -##### Error Response -##### Sample Call -##### Notes +* **URL Params** +* **Data Params** +* **Success Response** +* **Error Response** +* **Sample Call** +* **Notes** #### Append to the value for a handler key -##### URL -##### Method +* **URL** +* **Method** PUT -##### URL Params -##### Data Params -##### Success Response -##### Error Response -##### Sample Call -##### Notes +* **URL Params** +* **Data Params** +* **Success Response** +* **Error Response** +* **Sample Call** +* **Notes** ## Usage Example