go-rest-api

command module
v0.0.0-...-02fbc85 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

README

go-rest-api

ecommerce api-rest with basic CRUD operations (Create, Read, Update and Delete) products, suppliers, etc. Manage automatically invoice and shipping operations

How to use this repo?

Do it by yourself
  • Clone the repo
git clone https://github.com/AlexVonEinzbern/go-rest-api.git
  • Add an .env file in the main root of the project containing the environment variables with the database credentials. E.g. :
DB_HOST=host.docker.internal
DB_USER=voneinzbern
DB_PASSWORD=bacbabaBDBWUOB3242obf
DB_NAME=go-rest-api
  • Uncomment the followig lines on db/connection.go (Line 8):
//"github.com/joho/godotenv"

(Lines 15-19)

//err := godotenv.Load(".env")

//if err != nil {
//	log.Fatal("Error loading .env file")
//}
  • Uncomment the following line on Dockerfile (Line 27):
#COPY .env /
  • Build the project using Docker:
docker build -t go-rest-api .
  • Run the container:

  On Mac:

docker run -it -p 8080:8080 --env-file=".env" go-rest-api

  On Linux it is necessary to use the flag --add-host=host.docker.internal:host-gateway

docker run --add-host=host.docker.internal:host-gateway -it -p 8080:8080 --env-file=".env" go-rest-api
Use the API

https://go-rest-api.onrender.com/api/v1

Documentation

After the project is running, an interactive documentation created using Swagger can be visited on http://localhost:8080/swagger/index.html#/

Note: The online documentation can be found here.

  Some examples:

Fig 1. Documentation preview.

Fig 2. Example of GET request.

Fig 3. Example of POST request.

Fig 4. Example of PATH (UPDATE) request.

Fig 5. Example of GET request using date.

Fig 6. Example of DELETE request.

Fig 7. Example of model.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
Package docs GENERATED BY SWAG; DO NOT EDIT This file was generated by swaggo/swag
Package docs GENERATED BY SWAG; DO NOT EDIT This file was generated by swaggo/swag

Jump to

Keyboard shortcuts

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