Gin-boilerplate - Gin boilerplate preconfigured with basic rest api features

Overview

Gin Boilerplate


Build apis with gin faster with this template

Features

Validation errors

POST /api/register HTTP/1.1
Content-Type: application/json

{"email": "john.com", "password": "secure"}

Response

{
    "code": 400,
    "success": false,
    "errors": {
        "email": [
            "invalid email"
        ]
    }
}

Authentication middleware

// building authentication middleware
authMiddleware := middlewares.AuthMiddleware{
    Jwt: &jwtService,
    DB:  db,
}

// initializing route with authentication middleware
router.GET("/me", authMiddleware.Validate(jwt.AccessToken), authCtrl.GetMe())

// getting user in controller
user := c.MustGet("user").(*models.UserModel)

Http response builder

lib.HttpResponse(200).Message("User registered successfully").Send(c)

Response

{
     "code": "200",
     "success": true,
     "message": "User registered successfully"
}

Request body validation with validation middleware

// dto
type RegisterDto struct {
	Email    string `json:"email" form:"email" binding:"required,email,max=100"`
	Password string `json:"password" form:"password" binding:"required,max=100,min=8"`
	Name     string `json:"name" form:"name" binding:"required,max=100"`
	Status   string `json:"status" form:"status" binding:"required,max=150"`
}

// adding validation middleware in route
router.POST("/login", middlewares.Validate(&LoginDto{}), authCtrl.Login())

// retreiving the dto struct in controller
dto := c.MustGet("data").(*LoginDto)
Owner
Mohan barman
MERN Stack | Typescript | Linux Enthusiast
Mohan barman
Go (Golang) API REST with Gin FrameworkGo (Golang) API REST with Gin Framework

go-rest-api-aml-service Go (Golang) API REST with Gin Framework 1. Project Description Build REST APIs to support AML service with the support of exte

Tony Aizize 1 Nov 21, 2021
A barebones URL Shortener implementation in Go using Gin and MySQL. Also features a basic frontend.

URL Shortener in Go This is a barebones URL Shortener implementation in Go using the Gin web framework and MySQL. Also features a basic frontend. Loca

Shreyas Gupta 6 Dec 22, 2021
Dating-server - Go (Golang) API REST Template/Boilerplate with Gin Framework

go-rest-template Go (Golang) API REST Template/Boilerplate with Gin Framework 1.

null 1 Apr 3, 2022
Go-gin-ddd-cqrs - Clean api rest with Go, Gin and GORM

GOLANG API REST Clean api rest with Go, Gin and GORM. Clean Architecture with DD

Juan Cantón Rodríguez 12 Jul 25, 2022
Gin-errorhandling - Gin Error Handling Middleware is a middleware for the popular Gin framework

Gin Error Handling Middleware Gin Error Handling Middleware is a middleware for

Joseph Woodward 8 Jul 25, 2022
This is a small API that provides basic REST endpoints to shorten a URL

This is a small API that provides basic REST endpoints to shorten a URL, get information about the URL, update the URL, and get statistics on most accessed URLs.

Erick Henrique 0 Nov 16, 2021
Go-gin-mongo-api - A backend RESTful API built using golang, gin and mongoDB

go-gin-mongo-API This is a RESTful backend API which is developed using the gola

Humbe Jeffrey 6 Jul 19, 2022
REST API for a shoe store using Go and Gin Web Framework

REST API for a shoe store using Go and Gin Web Framework This API uses a local PostgreSQL database that's set through the /gopostgres/driverConfig.go

Nalbert Wattam 0 Dec 26, 2021
GinGoExample - Implement rest api using gin and go and mongodb

GinGoExample Implement rest api using gin and go and mongodb Optimizations using Singlton pattern to avoid repetetive commiunication with mongodb . Fe

Mehdi 0 Mar 25, 2022
Gin-easy-todo - golang 의 RESTful API 프레임워크 gin 을 활용해 아주 간단한 Todo 애플리케이션을 만들어보자.

목차 1. 요약 2. 목표 3. API 목록 4. 프로젝트 구조 5. 패키지 별 기능과 관계 6. 사전 작업 6.1. DB, Table 생성 6.2. 모듈 생성 6.3. 패키지 다운로드 7. Gin 작성 7.1. 데이터베이스 설정 7.2. 테이블, 스키마 정의 7.3.

jongbae_park 0 Jan 2, 2022
Go-service-gin - Simple Web api application developed in Golang and Gin

Simple Web api application developed in Golang and Gin Initial Tutorial URL http

Nurul Huda Robin 0 Jan 4, 2022
Tutorial: Deploying a basic Gin app on Jekyo

Tutorial: Deploying a basic Gin app on Jekyo Demo app here Prerequisites Make sure you have NodeJS, npm and git installed. If it's your first time usi

JEKYO LTD 0 Nov 1, 2021
License-API - Basic license based authentication API with discord account integration

License-API Basic license based authentication API with discord account integrat

null 2 Feb 18, 2022
Go Server/API boilerplate using best practices DDD CQRS ES gRPC

Go Server/API boilerplate using best practices DDD CQRS ES gRPC

Rafał Lorenz 643 Jul 31, 2022
Ecommerce-api - Rest api of e-commerce web application

E-commerce Rest API Swagger documentation to test api Domain diagram

Павел Шпаковский 10 Aug 3, 2022
Api-go-gin-viper - Simple representaion on how to implement CRUD functionality in API using Go programming language

Simple API implementaion in Go To Get Started Clone repo Run the command to clon

Vsevolod Drobyshev 1 Feb 18, 2022
Golang Simple Boilerplate with Gofiber & Gorm

Golang Simple Boilerplate with Gofiber & Gorm Boilerplate Structure config/ controller/ entity/ exception/ helper/ middleware/ model/ repository/ seed

Fikry Fahrezy 1 May 11, 2022
REST API for RabbitMQ, Write with Google Go(lang).

RabbitMQ HTTP API REST HTTP API for RabbitMQ, it's not RabbitMQ Management Plugin. Status: Under active development. Required: * RabbitMQ (2.8+) * Go(

陈小玉 108 Jul 11, 2022
Simple Bank is a simple REST API that allows users to perform transferences with each other.

Simple Bank is a simple REST API that allows users to perform transferences with each other. ?? Technologies Golang Docker PostgreSQ

Matheus Mosca 12 Feb 15, 2022