sample-api

module
v0.0.0-...-4489571 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 21, 2020 License: MIT

README

This project is a sample api in Golang created to help beginners in this tool.

Getting Started


First you need run two commands for download the dependencies.
1 - govendor init: create vendor path.
2 - govendor add +external: Add, inside vendor path, the dependencies.
Now, we'll started our service.

Run the command bellow, inside /cmd path. This command will create a binary file from a Go program.

go build main.go

system schema

After build the binary, run the bellow command to run the program.
./main

system schema

or simply

docker-compose up

system schema

Accessing the routes


Request:
http://localhost:8890/api/v1/version/
Response:
{
    "codResponse":"201",
    "Message":"I'm Ok",
    "version":{
        "major":"1",
        "minor":"0",
        "patch":"0"
    }
}
Now open the Postman, for exemple.
1 - Change the verb HTTP to POST
2 - Add the endpoint:
    - http://localhost:8890/api/v1/process/
3 - Access the aba named Body
Request:
{
	"code": 1, 
	"name": "Name"
}
Response:
{
    "codResponse":"201",
    "Message":"Process done...",
    "object":{
            "code":1,
            "name":"Name"
        }
}

License

This project is a sample api in Golang and open source software licensed as MIT.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL