…to semiboldy mars where others have marsed before.
This runs on port 1996 if you run locally (for the year Sojourner was launched of course) and can be found running on default HTTP 80 at https://sojourner.zjr.io.
Creates and returns a 'new' rover object.
-
URL
/rover
-
Method:
GET
-
Success Response:
- Code: 200
Content:{ id: 12, x: 0, y: 0, direction: 'N' }
- Code: 200
-
Sample Call:
curl -X GET "https://sojourner.zjr.io/rover"
Rotates a given rover to the right or left.
-
URL
/rover/{id}/rotate
-
Method:
PUT
-
URL Params
Required:
id=[integer]
-
Query Params
Required:
direction=[string <right, left>]
-
Success Response:
Returns rover with updated cardinal direction.
-
Sample Call:
curl -X PUT "https://sojourner.zjr.io/rover/0/rotate?direction=right"
-
Notes:
These query params definitely could have been better as body params…
Moves a given rover forward or backward.
-
URL
/rover/{id}/move
-
Method:
PUT
-
URL Params
Required:
id=[integer]
-
Query Params
Required:
direction=[string <forward, backward>]
-
Success Response:
Returns rover with updated coordinates.
-
Error Response:
This route can fail if an obstacle is encountered.
- Code: 500
Content:{ http_code: 500, code: 101, message: 'Obstacle encountered at 3, 0' }
- Code: 500
-
Sample Call:
curl -X PUT "https://sojourner.zjr.io/rover/0/move?direction=forward"
-
Notes:
These query params definitely could have been better as body params…
Send multiple move and rotate commands in batches.
-
URL
/rover/{id}/cmd-queue
-
Method:
PUT
-
URL Params
Required:
id=[integer]
-
Body Params
Required:
{ "cmds": [ { "cmd": "move", "value": "forward" }, { "cmd": "rotate", "value": "right" }, { "cmd": "move", "value": "forward" } ]}
can also be shortened like:
{ "cmds": [ { "cmd": "m", "value": "forward" }, { "cmd": "r", "value": "right" }, { "cmd": "m", "value": "forward" } ]}
-
Success Response:
Returns rover with updated coordinates and facing direction.
-
Error Response:
This route can fail if an obstacle is encountered.
- Code: 500
Content:{ http_code: 500, code: 101, message: 'Obstacle encountered at 3, 0' }
- Code: 500
-
Sample Call:
curl -X PUT -H "Content-Type: application/json" -d '{ "cmds": [ { "cmd": "move", "value": "forward" }, { "cmd": "rotate", "value": "right" }, { "cmd": "move", "value": "forward" } ]}' "https://sojourner.zjr.io/rover/0/cmd-queue"
-
Notes:
Body params are in JSON only