The role of this service is to create, delete and update boolean values with authorisation with token.
To create docker image
docker build . -t go-boolean
To run docker container
docker run -p 8080:8080 go-boolean -e DOCK_USR=_ -e DOCK_PASS=_ -e DOCK_DB=_ -e DOCK_PORT= _
docker pull raghavtayal/go-boolean
docker run -p 8080:8080 raghavtayal/go-boolean -e DOCK_USR=_ -e DOCK_PASS=_ -e DOCK_DB=_ -e DOCK_PORT= _
To build the app locally. In root directory use :
go mod download
go build .
To run the app
./Go_boolean_service
Create a boolean and return authentication token.
curl -X POST http://localhost:8080
--header "Content-Type: application/json" --data '{"value": true, "key": "bool_key"}'
{
"id":"0e7aba578a6d-bc3d-9066-eaf5ec13e126",
"key":"bool_key",
"token":"eyJhbGciOiJIUzI1NiIsImtpZCI6InNpZ25pbl8xIiwidHlwIjoiSldUIn0.eyJleHAiOjE2MDA4ODM4NTUsImlkIjoiMGU3YWJhNTc4YTZkLWJjM2QtOTA2Ni1lYWY1ZWMxM2UxMjYifQ.x1bjQdauu0FzBNBrubmsnJQRDQKEuHHH-cTLxovYxeE",
"value":true
}
After authentication with token return the boolean with corresponding ID
curl http://localhost:8080/[id]
curl http://localhost:8080/"0e7aba578a6d-bc3d-9066-eaf5ec13e126"
{
"id":"0e7aba578a6d-bc3d-9066-eaf5ec13e126",
"key":"bool_key",
"value":true
}
After authentication with token, updates the boolean corresponding to the given ID
curl -X PATCH http://localhost:8080/[id]
--header "Content-Type: application/json"
--data '{"value": true, "key": "new_bool"}'
--header "Authorization: Bearer <token> "
curl -X PATCH http://localhost:8080/"0e7aba578a6d-bc3d-9066-eaf5ec13e126"
--header "Content-Type: application/json"
--data '{"value": true, "key": "bool_newKey"}'
--header "Authorization: Bearer eyJhbGciOiJIUzI1NiIsImtpZCI6InNpZ25pbl8xIiwidHlwIjoiSldUIn0.eyJleHAiOjE2MDA4ODM4NTUsImlkIjoiMGU3YWJhNTc4YTZkLWJjM2QtOTA2Ni1lYWY1ZWMxM2UxMjYifQ.x1bjQdauu0FzBNBrubmsnJQRDQKEuHHH-cTLxovYxeE"
{
"id":"0e7aba578a6d-bc3d-9066-eaf5ec13e126",
"key":"new_bool",
"value":true
}
After authentication with token, deletes the boolean corresponding to the given ID
curl -X DELETE http://localhost:8080/[id] --header "Authorization: Bearer <token>"
curl -X DELETE http://localhost:8080/"0e7aba578a6d-bc3d-9066-eaf5ec13e126"
--header "Authorization: Bearer eyJhbGciOiJIUzI1NiIsImtpZCI6InNpZ25pbl8xIiwidHlwIjoiSldUIn0.eyJleHAiOjE2MDA4ODM4NTUsImlkIjoiMGU3YWJhNTc4YTZkLWJjM2QtOTA2Ni1lYWY1ZWMxM2UxMjYifQ.x1bjQdauu0FzBNBrubmsnJQRDQKEuHHH-cTLxovYxeE"
HTTP 204 No Content