Skip to content

puneethreddy20/go-api-storage-mongodb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-api-storage-mongodb

API which stores the requests data into mongo db.

How to build and run the application:

To run the application you would need docker installed. Install docker first. Unzip the package

$ cd go-api-storage-mongodb/init-database

//Create a docker custom network
$ sudo docker network create --subnet=172.18.0.0/16 mycustomnet

//build a image with dockerfile
$ sudo docker build -t mongo-db .

//Run the container. Which starts the db service on port 27017

$ sudo docker run -d -p 27017:27017 --net mycustomnet --ip 172.18.0.10 mongo-db

$ cd ..

//build a image with dockerfile
$ sudo docker build -t api .

//Run the container. Which starts the API service on port 8080
sudo docker run -d -p 8080:8080 --net mycustomnet --ip 172.18.0.20 api

On the host machine open browser and visit http://localhost:8080 .

Functionalities:

Assuming CandidateNames are unique.

Please the below commands for appropriate operations.

  1. Create Candidate/User
    curl -H "Accept: application/json" -H "Content-type: application/json" -X POST -d '{"name":"user1","age":"23","phone":"000-000-0000"}' http://localhost:8080/createUser

    curl -H "Accept: application/json" -H "Content-type: application/json" -X POST -d '{"name":"user2","age":"27","phone":"001-000-1000"}' http://localhost:8080/createUser

    curl -H "Accept: application/json" -H "Content-type: application/json" -X POST -d '{"name":"user3","age":"32","phone":"100-100-1000"}' http://localhost:8080/createUser

  1. Delete Candidate/User
    curl http://localhost:8080/removeUser/?username=user3

  1. Create or Update Candidate/User Tags(key-value pairs)
curl -H "Accept: application/json" -H "Content-type: application/json" -X POST -d '{"lastname":"lastuser1","state":"CA"}' http://localhost:8080/create-updateTags/?username=user1

  1. Delete Candidate/User Tags(key-value pairs)
        curl "http://localhost:8080/deleteTags/?username=user1&deletetags=age,lastname"

  1. Listall Candidate/User Tags(key-value pairs)
          curl http://localhost:8080/listTags/?username=user1

About

API which stores the requests data into mongo db

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published