GithubHelp home page GithubHelp logo

go_boolean_service's Introduction

Go_boolean_service

The role of this service is to create, delete and update boolean values with authorisation with token.

Installation

Docker(locally)

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(from DockerHub)

  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= _

Source

To build the app locally. In root directory use :

  go mod download
  go build .

To run the app

  ./Go_boolean_service

API

HTTP

POST /

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
  }

GET /:id

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
  }

PATCH /:id

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
  }

DELETE /:id

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

go_boolean_service's People

Contributors

raghavtayal avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.