Skip to content

Go playground Web API using Gin, Swaggo, CORS gin's middleware and GORM

License

Notifications You must be signed in to change notification settings

joacod/go-playground-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go Playground

Go playground Web API using Gin, Swaggo, CORS gin's middleware and GORM

Notes

Go version 1.14

The idea of this project is to provide all the apis that exists in my other repositories NetCore.Playground.Api and node-playground-api

What we get from this:

  • We practice different approaches in Go
  • We can compare Go implementations with the same ones written in .NetCore and Node.js
  • We have three versions of the same Web Api written in different languages, that can be switched from a UI having the exact same results

I have created three UI projects to consume the APIs created here, you can use either of the following repositories:

Prerequisites

Installation and Setup

  1. Download Gin framework: go get github.com/gin-gonic/gin
  2. Download Swag for Go: go get -u github.com/swaggo/swag/cmd/swag
  3. Download gin-swagger by using:
$ go get -u github.com/swaggo/gin-swagger
$ go get -u github.com/swaggo/files
  1. Download MySQL driver for Go: go get github.com/go-sql-driver/mysql
  2. Download GORM: go get github.com/jinzhu/gorm
  3. Go to the file database/Database.go and update DBName, Host, Port, User and Password according to your local environment configuration

How to Run it

  1. From the terminal: go run playground
  2. Once it's running, go to a browser
  3. Hit the following url http://localhost:8080/swagger/index.html

Generating Swagger documentation

If you change or add new apis:

  1. Make sure they have the proper General API annotations
  2. Run the Swaggo command to regenerate the documentation: swag init
  3. That's all 😃

What you will find so far ✔️

  • Web API created with Gin
  • Swagger documentation of the APIs usign Swaggo
  • CRUD operations using GORM and MySQL

About

Go playground Web API using Gin, Swaggo, CORS gin's middleware and GORM

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages