Skip to content

GIN Project starter with logger, jwt auth, and more

License

Notifications You must be signed in to change notification settings

reshimahendra/gin-RESTAPI-starter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

83 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Yet Another Golang RESTfull API

A quick story about this starter-kit

So, when I tried to write my first Golang project, especially for web api, I realy don't know how to structure my project directory, file managing the file, and so on. Frequently I search for hours on Github or Googling topics regarding the best practice on how to structuring Golang Webapp project, but the deeper I dive, the confuser I get. Technically, most of the already available Golang RESTFULL API Starter Kit that I found on the net is good, but sometimes it overkill. Some of them also great, but missing some part that I need. Therefore I made my own so it will also aligned with my coding writting style as well as minimalizing the 'confusion' I may get when depending on others starter-kit. This starter-kit may not for you as writting/ programming style is personal prefference and relative for every person, but feel free to use it.

STILL IN PROGRESS

Table of Content

  1. Quick Review
  2. Directory Structure
  3. Getting Started

1. Quick review

This YET ANOTHER golang RESTFull API is using below module:

  • Gin web framework, fast and easy
  • Gorm ORM, so you doesn't need to dive to deep on the SQL. Support for PostgreSQL, MySQL or MariaDB, and Sqlite3
  • Viper for easy configuration, support yaml, toml, json, and more...
  • Golang JWT for authentification
  • Logrus for nice and easy logging feature from sirupsen
  • Air Hot Reload module for faster development

Writting pattern:

model-> repository-> service-> handler-> router (api endpoint)

Back to Table of Content or back to Top

2. Directory structure

project-directory
|-- cmd
|-- |-- app
|-- |-- | server
|-- |-- docker
|-- config
|-- dist
|-- internal
|-- |-- account
|-- |-- |-- handler
|-- |-- |-- model
|-- |-- |-- repository
|-- |-- |-- router
|-- |-- |-- service
|-- |-- blog
|-- |-- |-- handler
|-- |-- |-- model
|-- |-- |-- repository
|-- |-- |-- router
|-- |-- |-- service
|-- |-- database
|-- |-- |-- error 
|-- |-- |-- model
|-- |-- pkg
|-- pkg
|-- |-- logger
|-- |-- middleware
|-- vendor
|-- go.mod
|-- go.sum
|-- README.md
|-- Makefile

Back to Table of Content or back to Top

3. Getting started

To run the server:

make run

To build the project

make build

Back to Table of Content or back to Top

Todo

From the list of requirements, I still have to:

  • Add test
  • Add docs
  • Add swagger
  • Add simple blogging app

LICENSE

MIT

About

GIN Project starter with logger, jwt auth, and more

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published