desafio-api-rest

command module
v0.0.0-...-81b3d55 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2024 License: MIT Imports: 5 Imported by: 0

README

DESAFIO - Criando Primeira API REST com GO

Escrever uma APIREST que a vovó possa guardar dados dos seus clientes


tools:
  • linux
  • goland ide
  • go1.22.0
  • package gorilla/mux

routes
API ROUTE DESCRIPTION STATUS
[GET] /customers Retrieve all the customers 200
[GET] /customer/{id} Retrieve a customer by ID 200
[POST] /customers Add a new customer 200
initial set of data
id firstName lastName email address
1 Ana Maria ana@email.com São Paulo SP
2 Maria Clara maria@email.com Belo Horizonte MG

homepage
curl --location 'http://localhost:8010/'
200 OK
Bem vinde à página da Vovó
get all customers
curl --location 'http://localhost:8010/customers'
200 OK
[
  {
    "id": 1,
    "firstName": "Ana",
    "lastName": "Maria",
    "email": "ana@email.com",
    "address": {
      "city": "São Paulo",
      "state": "SP"
    }
  },
  {
    "id": 2,
    "firstName": "Maria",
    "lastName": "Clara",
    "email": "maria@email.com",
    "address": {
      "city": "Belo Horizonte",
      "state": "MG"
    }
  }
]
get all customer by ID
curl --location 'http://localhost:8010/customer/1'
200 OK
{
  "id": 1,
  "firstName": "Ana",
  "lastName": "Maria",
  "email": "ana@email.com",
  "address": {
    "city": "São Paulo",
    "state": "SP"
  }
}
add a customer
curl --location 'http://localhost:8010/customers' \
--header 'Content-Type: application/json' \
--data-raw '{
    "firstName": "John",
    "lastName": "Doe",
    "email": "john@email.com",
    "address": {
        "city": "Salvador",
        "state": "BA"
    }
}'
200 OK
{
    "id": 3,
    "firstName": "Joao",
    "lastName": "Doe",
    "email": "joao@email.com",
    "address": {
        "city": "Salvador",
        "state": "BA"
    }
}

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

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