go-rest-api-boilerplate

module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2020 License: Apache-2.0

README

GO RESTful API Boilerplate

This boilerplate makes it easy to start a project by following the recommended structure from golang-standards.

The purpose of this boilerplate is to have a solid structure to build medium to big apps and makes it easier for teams to work in parallel.

Features

The following feature set is a minimal selection of typical Web API requirements:

How to start

  • Clone this repository
  • Use go mod vendor
  • Create a postgres database and set environment variables for your database accordingly if not using same as default
  • Run go run cmd/server/main.go migrate to migrating PostgreSQL database
  • Run application with go run cmd/server/main.go
  • If you want to use this boilerplate for Production, change ENV from development to production

API Routes

You can see the routes on the folder api/spec/swagger.json, this boilerplate use OPENAPI 3.0.3

ENV Variable

Name Type Default Description
MAIN_URL string localhost HTTP address
ENV string development Status project, run on development or production
PORT string :5000 HTTP port
HASH_KEY string wkwkwkwk You should change the default hash key, this variable is used for hashing your password
JWT_SIGN_KEY string wadidaw You should change the default JWT_SIGN_KEY, this variable used for signed the JWT token
JWT_EXPIRATION int 15 JWT Access token expiry, count with minutes
JWT_REFRESH_EXPIRATION int 1 JWT refresh token expiry, count with hours
DB_HOST string 0.0.0.0 Database tcp address
DB_PORT stirng 5432 Database port
DB_USER string postgres Database username
DB_USER string password Database password
DB_DATABASE string myapp Your database name
REDIS_HOST string localhost:6379 Redis tcp address
REDIS_PASSWORD string Redis password
MAIL_HOST string SMTP Host
MAIL_PORT int SMTP Port
MAIL_SECURE int If your SMTP use TLS, filled with 1 if not fileed with 0
MAIL_USER string SMTP user
MAIL_PASSWORD string SMTP password
MAIL_FROM string Mail header sender

Directories

Path Synopsis
cmd
internal
pkg
cli
log

Jump to

Keyboard shortcuts

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