A Player manager - backend REST server
(see: https://thenewstack.io/make-a-restful-json-api-go/)
Get the dependancies:
make deps
The application data is stored in the "${HOME}/players-api" directory.
Given the following variables are set:
USER=foo
PASSWORD=bar
ENDPOINT=localhost:4201
players-apiCOMMAND="/person"
curl -X GET -u "${USER}:${PASSWORD}" ${ENDPOINT}${COMMAND} \
--header "Accept: application/json"httpStatus: 200
response: { "people":[1001,1002] }COMMAND="/person"
cat <<EOT > data.json
{
"name": "xxx"
}
EOT
curl -X POST -u "${USER}:${PASSWORD}" ${ENDPOINT}${COMMAND} \
--header "Content-Type: application/json" \
--data-binary @data.jsonhttpStatus: 200
response: { "message":"ok" }COMMAND="/person"
ID=1002
curl -X DELETE -u "${USER}:${PASSWORD}" ${ENDPOINT}${COMMAND}/${ID}httpStatus: 200
response: {"message":"ok"}COMMAND="/person"
ID=1002
curl -X GET -u "${USER}:${PASSWORD}" ${ENDPOINT}${COMMAND}/${ID}httpStatus: 200
response: { "person":{"name":"FRED"} }