/simple-rest-go

Simple REST API using golang

Primary LanguageGo

Simple REST API using GO

Requirements

Dependencies

Install

  • make install-deb

Build

  • make build thats will be generate 3 binary file for linux, macos, windows in ./build or you can specified build using below command :
make build-linux
make build-darwin
make build-windows

Run

  • make run or you can run the binary file in ./build directory after build success

Documentation

  • BASE_URL=http://localhost:3000
  • GET /products get all persons

response example

{
    "code": 200,
    "data": [
        {
            "id": 1,
            "FirstName": "",
            "LastName": "",
            "Avatar": "",
            "Age": 0
        },
        {
            "id": 2,
            "FirstName": "",
            "LastName": "",
            "Avatar": "https://api.adorable.io/avatars/120/jarjitsingh.png",
            "Age": 10
        },
        {
            "id": 3,
            "FirstName": "jarjit",
            "LastName": "singh",
            "Avatar": "https://api.adorable.io/avatars/120/jarjitsingh.png",
            "Age": 10
        }
    ],
    "msg": "success"
}
  • GET /persons/{id} get person by id

response example

{
    "code": 200,
    "msg": "Success",
    "data": {
        "id": 4,
        "FirstName": "jarjit",
        "LastName": "singh",
        "Avatar": "https://api.adorable.io/avatars/120/jarjitsingh.png",
        "Age": 10
    }
}
  • POST /persons insert person data

request example

{
	"firstname":"jarjit",
	"lastname":"singh",
	"avatar":"https://api.adorable.io/avatars/120/jarjitsingh.png",
	"age":10
}

response example

{
    "code": 200,
    "data": {
        "id": 4,
        "FirstName": "jarjit",
        "LastName": "singh",
        "Avatar": "https://api.adorable.io/avatars/120/jarjitsingh.png",
        "Age": 10
    },
    "msg": "success"
}