Skip to content

Latest commit

 

History

History
115 lines (105 loc) · 2.11 KB

File metadata and controls

115 lines (105 loc) · 2.11 KB

terraform-example-employee-server

Its a simple golang server which stores employee record in mongodb.

Build locally

Run the following command to create application binary locally

$ make install

Create docker image

Run the following command to create docker image

$ make image

Run locally

Run the following command to run locally

$ docker compose --file=docker-compose-up.yaml up

Sample Request-Response

GET: http://localhost:8000/api/getAllEmployees

  • Response:
[
    {
        "_id": "61d70dc9b3624419697383de",
        "empID": "so9091",
        "fullName": "sourav patnaik",
        "company": {
            "companyName": "IBM",
            "companyAddress": "Hyderabad"
        }
    },
    {
        "_id": "61d7112026f3263c35d4cf68",
        "empID": "so9093",
        "fullName": "Ammy Zen",
        "company": {
            "companyName": "Redhat",
            "companyAddress": "Pune"
        }
    }
]

POST: http://localhost:8000/api/addEmployee

  • Request Body:
{
    "empID": "so9091",
    "fullName": "sourav patnaik",
    "company": {
        "companyName": "IBM",
        "companyAddress": "Hyderabad"
    }
}
  • Response:
[
    {
        "_id": "61d70dc9b3624419697383de",
        "empID": "so9091",
        "fullName": "sourav patnaik",
        "company": {
            "companyName": "IBM",
            "companyAddress": "Hyderabad"
        }
    },
    {
        "_id": "61d7112026f3263c35d4cf68",
        "empID": "so9093",
        "fullName": "Ammy Zen",
        "company": {
            "companyName": "Redhat",
            "companyAddress": "Pune"
        }
    }
]

PUT: http://localhost:8000/api/updateEmployeeByID

  • Request Body:
{
    "empID": "so9091",
    "fullName": "sourav ranjan patnaik",
    "company": {
        "companyName": "IBM",
        "companyAddress": "Austin"
    }
}
  • Response
{
    "MatchedCount": 1,
    "ModifiedCount": 1,
    "UpsertedCount": 0,
    "UpsertedID": null
}

DELETE: http://localhost:8000/api/DeleteEmployeeByID?empID=so9092

  • Response:
{
    "DeletedCount": 0
}