gin-sqlx-example

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

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

Go to latest
Published: Mar 27, 2023 License: MIT Imports: 7 Imported by: 0

README

GIN SQLX EXAMPLE

Sample implementation gin, postges using sqlx.

This project will create a database named sampledb along with a table named Animal :

sampledb=# SELECT * FROM animals;
 id | name | age | description
----+------+-----+-------------
(0 rows)

Prerequisites :

  • install docker

Running :

  • make environment
  • create file .env based on .env.sample
  • make server
  • app will running in port 8080! Note : you can use command make help for showing list available commands.

Testing Locally using curl :

  1. Create animal
curl --location 'http://localhost:8080/animals' \
--header 'Content-Type: application/json' \
--data '{
    "name": "cow",
    "age": 20,
    "description": "beautiful cow"
}'
  1. List all animal
curl --location 'http://localhost:8080/animals'
  1. Detail animal
curl --location 'http://localhost:8080/animals/11'
  1. Update animal
curl --location --request PATCH 'http://localhost:8080/animals/12' \
--header 'Content-Type: application/json' \
--data '{
    "name": "cat",
    "age": 15,
    "description": "beautiful cat update"
}'
  1. Delete animal
curl --location --request DELETE 'http://localhost:8080/animals/13'

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