- A RESTful HTTP API listening to port
8080 - 3 endpoints
- create an order
- take an order
- list orders
- Using direction api from google api
- Mysql as DB
- using
start.shto do all the initialisation and installation using docker - simple unit test -
./server/api/order_test.go
# 0. go to project folder
# 1. install dependencies
$ dep init
$ dep ensure
# 2.1 run in debug mode
$ mkdir devConfig
$ cp config/config.yaml ./devConfig
$ APP_ENV=DEBUG go run ../cmd/yay/main.go
# 2.2 run in prod mode
# add config yaml in docker folder
$ bash start.sh-
Method:
POST -
URL path:
/order -
Request body:
{ "origin": ["START_LATITUDE", "START_LONGTITUDE"], "destination": ["END_LATITUDE", "END_LONGTITUDE"] } -
Response:
Header:
HTTP 200Body:{ "id": <order_id>, "distance": <total_distance>, "status": "UNASSIGN" }or
Header:
HTTP 500Body:{ "error": "ERROR_DESCRIPTION" }
-
Method:
PUT -
URL path:
/order/:id -
Request body:
{ "status":"taken" } -
Response: Header:
HTTP 200Body:{ "status": "SUCCESS" }or
Header:
HTTP 409Body:{ "error": "ORDER_ALREADY_BEEN_TAKEN" }
-
Method:
GET -
Url path:
/orders?page=:page&limit=:limit -
Response:
[ { "id": <order_id>, "distance": <total_distance>, "status": <ORDER_STATUS> }, ... ]