Giter Site home page Giter Site logo

golangapirest's Introduction

GOLANG API REST

So Go Version
Database Database
Report
Repo Size Exec Size
MIT License

Installation GoLang

  sudo apt install snapd
  sudo snap install go

Run Locally

  # Install dependencies
  go build
  # Start the server linux
  ./golangApiRest

ENV (.env)

  GOOGLE_IAM_KEY = "./security/bigquery_key.json"
  BIGQUERY_PROJECT_ID = "project-123456789"
  GOOGLE_CHAT_WEBHOOK = "https://chat.googleapis.com/v1/spaces/AAAAgOxrNhU/messages?key=AIzaSyDdI0hCZtE6vySjMm-WEfRq3CPzqKqqsHI&token=zk3322S04V0WdHW9y_4Zsg62CUZP9HvIvy0000uJ1qo%3D"

  POSTGRESQL_HOST = "localhost"
  POSTGRESQL_USER = "postgres"
  POSTGRESQL_PASSWORD = "postgres"
  POSTGRESQL_DBNAME = "golangApiRest"
  POSTGRESQL_PORT = "5432"

Tables

Locate: Biquery
Name: users
AutoMigrate: false

Column Type Compilate
id STRING NULLABLE
status STRING NULLABLE
name STRING NULLABLE
phone STRING NULLABLE
created_at DATETIME NULLABLE
updated_at DATETIME NULLABLE

Locate: Postgresql
Name: products
AutoMigrate: true
Soft Delete: deleted_at

Column Type
id BIGINT
name TEXT
value NUMERIC
created_at TIMESTAMP
updated_at TIMESTAMP
deleted_at TIMESTAMP

API Reference

# Monitoring point

Request

  GET http://localhost:8001/ping

Response

  ### Status code: 200
  {
    "msg": "pong"
  }

So

# User point's

-- Create User

Request

  POST http://localhost:8001/user
  Content-Type: application/json

  {
    "name": "Testenildos",
    "phone" : "5562981919191",
    "status": "Registred"
  }

Response

  ### Status code: 201
  {
    "id": "b11b1522-cb7c-48b8-9b35-27ec3a343e34",
    "name": "Testenildos",
    "phone": "5562981919191",
    "status": "Registred",
    "created_at": "2022-09-24T23:01:15.748503488",
    "updated_at": "2022-09-24T23:01:15.748503488"
  }

So

-- List User

Request

  GET http://localhost:8001/user/:id

Response

  ### Status code: 200
  [
    {
      "id": "c8b948cd-4172-40a1-924a-fe815214f659",
      "name": "Testenildfffffo",
      "phone": "5562981921119191",
      "status": "Registr11ed",
      "created_at": "2022-09-22T18:31:17",
      "updated_at": "2022-09-22T18:31:17"
    }
  ]

So

Request

  GET http://localhost:8001/user

Response

  ### Status code: 200
  [
    {
      "id": "c8b948cd-4172-40a1-924a-fe815214f659",
      "name": "Testenildfffffo",
      "phone": "5562981921119191",
      "status": "Registr11ed",
      "created_at": "2022-09-22T18:31:17",
      "updated_at": "2022-09-22T18:31:17"
    },
    {
      "id": "ac668339-beee-46e6-87c5-8a482e5d9d26",
      "name": "Testenildo",
      "phone": "5562981919191",
      "status": "Registred",
      "created_at": "2022-09-22T18:31:22",
      "updated_at": "2022-09-22T18:31:22"
    },
    {
      "id": "b11b1522-cb7c-48b8-9b35-27ec3a343e34",
      "name": "Testenildos",
      "phone": "5562981919191",
      "status": "Registred",
      "created_at": "2022-09-24T23:01:15",
      "updated_at": "2022-09-24T23:01:15"
    }
  ]

So

-- Update User

Request

  PUT http://localhost:8001/user/:id
  Content-Type: application/json
  
  {
    "status": "Processed"
  }

Response

  ### Status code: 200

So

-- Delete User

Request

  DELETE http://localhost:8001/user/:id

Response

  ### Status code: 200

So


# Products point's

-- Create Product

Request

  POST http://localhost:8001/product
  Content-Type: application/json

  {
    "name": "balinha",
    "value": 0.11
  }

Response

  ### Status code: 201
  {
    "id": 1,
    "name": "balinha",
    "value": 0.11,
    "created_at": "2022-09-25T19:49:19.758414735-03:00",
    "updated_at": "2022-09-25T19:49:19.758414735-03:00"
  }

So

-- List Product

Request

  GET http://localhost:8001/product/:id

Response

  ### Status code: 200
  [
    {
      "id": 1,
      "name": "balinha",
      "value": 0.11,
      "created_at": "2022-09-25T19:49:19.758414-03:00",
      "updated_at": "2022-09-25T19:49:19.758414-03:00"
    }
  ]

So

Request

  GET http://localhost:8001/product

Response

  ### Status code: 200
  [
    {
      "id": 1,
      "name": "balinha",
      "value": 0.11,
      "created_at": "2022-09-25T19:49:19.758414-03:00",
      "updated_at": "2022-09-25T19:49:19.758414-03:00"
    },
    {
      "id": 2,
      "name": "Bola",
      "value": 10.5,
      "created_at": "2022-09-25T19:52:01.388815-03:00",
      "updated_at": "2022-09-25T19:52:01.388815-03:00"
    }
  ]

So

-- Update Product

Request

  PUT http://localhost:8001/product/:id
  Content-Type: application/json
  
  {
    "value": 11.00
  }

Response

  ### Status code: 200
  {
    "id": 2,
    "name": "Bola",
    "value": 11,
    "created_at": "2022-09-25T19:52:01.388815-03:00",
    "updated_at": "2022-09-25T19:53:54.586532334-03:00"
  }

So

-- Delete Product [ Soft Delete ]

Request

  DELETE http://localhost:8001/product/:id

Response

  ### Status code: 200

So

License

MIT

golangapirest's People

Contributors

braullio avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.