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

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
Similar Resources

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

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

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

Feb 18, 2022

Ecommerce-api - Rest api of e-commerce web application

Ecommerce-api - Rest api of e-commerce web application

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

Jan 2, 2023

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

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

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

Jan 6, 2023

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

Feb 18, 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(

Aug 29, 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

Feb 15, 2022

Sample Go REST API implementation with DDD using Clean Architecture.

This layer is a part developed for client-side (mobile, web, etc.) applications to access our domain. It will forward the requests from this layer to the application layer and expose the response it receives from the application layer.

Jan 3, 2023
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

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

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.

Apr 3, 2022
Go-gin-ddd-cqrs - Clean api rest with Go, Gin and GORM
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

Oct 21, 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

Sep 19, 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

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.

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

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

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

Mar 25, 2022
Gin-easy-todo - golang 의 RESTful API ν”„λ ˆμž„μ›Œν¬ gin 을 ν™œμš©ν•΄ μ•„μ£Ό κ°„λ‹¨ν•œ Todo μ• ν”Œλ¦¬μΌ€μ΄μ…˜μ„ λ§Œλ“€μ–΄λ³΄μž.
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.

Jan 2, 2022