API_FeirasLivres

command module
v0.0.0-...-f619c18 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2022 License: Apache-2.0 Imports: 4 Imported by: 0

README

API_FeirasLivres

API developed to use data made available in Feiras Livres and apply a simple CRUD. For documentation read Documentation

Setup

  • Run docker and get hostname
docker-compose up
docker-compose exec postgres sh
hostname -i
  • Open pgAdmin and create server. Username and Password can be found here
right click on "Servers->Register->Server..."
give it a name and in "Connection" set Hostname/address with the hostname given by docker
add login and pass

Run

To run API just make sure that docker image in up and:

docker-compose up
go run main.go

API

This project car create, delete, update a fair and also can read the data filtering by: district, region, name, neighbourhood and ID. Every method expect Status:200 and JSON content-type as show bellow:

Req Endpoint Description Success Warning Error
POST /api/fairs Create a new fair in database Status:200 - JSON - Status: 500
GET /api/fairs Read all fairs from database Status:200 - JSON Status: 204 Status: 500
PUT /api/fairs/id/{searchParam} Update a fair by given id Status:200 - JSON - Status: 500
DELETE /api/fairs/id/{searchParam} Delete a fair by given id Status:200 - JSON - Status: 500
GET /api/fairs/district/{searchParam} Read fairs with given district Status:200 - JSON Status: 204 Status: 500 or Status: 400
GET /api/fairs/region/{searchParam} Read fairs with given region Status:200 - JSON Status: 204 Status: 500 or Status: 400
GET /api/fairs/name/{searchParam} Read fairs with given fair name Status:200 - JSON Status: 204 Status: 500 or Status: 400
GET /api/fairs/neighbourhood/{searchParam} Read fairs with given neighbourhood Status:200 - JSON Status: 204 Status: 500 or Status: 400
GET /api/fairs/id/{searchParam} Read fairs with given id Status:200 - JSON Status: 204 Status: 500 or Status: 400

Endpoint Examples

[
    {
        "id": 810,
        "longitude": "-46776674",
        "latitude": "-23674371",
        "set_cen": "355030819000051",
        "area_p": "3550308005232",
        "cod_dist": "19",
        "district": "CAPAO REDONDO",
        "cod_sub_pref": "17",
        "sub_pref": "CAMPO LIMPO",
        "region_Five": "Sul",
        "region_Eight": "Sul 2",
        "name_fair": "JARDIM JANGADEIRO",
        "record": "3100-3",
        "street": "RUA ROSARIO SCAMARTI",
        "neighbourhood": "JD JANGADEIRO",
        "reference": "TV RUA ROSARIO ESCARNADI"
    }
]

body


    {
        "longitude": "-46776674",
        "latitude": "-23674371",
        "set_cen": "355030819000051",
        "area_p": "3550308005232",
        "cod_dist": "19",
        "district": "CAPAO REDONDO",
        "cod_sub_pref": "17",
        "sub_pref": "CAMPO LIMPO",
        "region_Five": "Sul",
        "region_Eight": "Sul 2",
        "name_fair": "JARDIM JANGADEIRO",
        "record": "3100-3",
        "street": "RUA ROSARIO SCAMARTI",
        "neighbourhood": "JD JANGADEIRO",
        "reference": "TV RUA ROSARIO ESCARNADI"
    }

response

  {
    "id": 888,
    "longitude": "-46776674",
    "latitude": "-23674371",
    "set_cen": "355030819000051",
    "area_p": "3550308005232",
    "cod_dist": "19",
    "district": "CAPAO REDONDO",
    "cod_sub_pref": "17",
    "sub_pref": "CAMPO LIMPO",
    "region_Five": "Sul",
    "region_Eight": "Sul 2",
    "name_fair": "JARDIM JANGADEIRO",
    "record": "3100-3",
    "street": "RUA ROSARIO SCAMARTI",
    "neighbourhood": "JD JANGADEIRO",
    "reference": "TV RUA ROSARIO ESCARNADI"
  }

LOG

  • Log Simple log to register API behavior

TEST

To run the tests:

docker-compose up
go test

We use a Mock models.Fair to run all the GET, POST PUT and DELETE end point's.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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