go-gin-gorm-rest-example

module
v0.0.0-...-f330cb9 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2021 License: MIT

README

go-gin-gorm-rest-example

Simple Go authenticated RESTful api server built with Gin and Gorm.
It uses Postgres as main DB and Redis to handle client sessions.

Development

Start the server using docker-compose up

Start devmode with docker-compose
  • Start the required services with the command docker-compose up redis postgres
  • Start Go in watch mode with Gow make watch

Build binary

  • Build dynamically linked binary with make build
  • Build statically linked binary with make build-static

Build Docker image

Build docker image with make build-docker

Create the first user

Connect to Postgres with your favorite client and insert
INSERT INTO public.users (id, created_at, updated_at, deleted_at, email, "password", "level") VALUES(1, NULL, NULL, NULL, 'demo@demo.demo', 'demo', 'admin');
Now you can login to the server with

{
  "email": "demo@demo.demo",
  "password": "demo",
  "level": "admin"
}

Directories

Path Synopsis
cmd
pkg
db

Jump to

Keyboard shortcuts

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