REST API boilerplate built with go and clean architecture - Echo Framework

GO Boilerplate

Go Reference License: MIT Go Report Card

Prerequisite

Install go-migrate for running migration

https://github.com/golang-migrate/migrate

App requires 2 database (postgreSQL and redis server), run from your local machine or run it using docker with the following command

# run postgreSQL
docker run -d -p 5432:5432 -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=postgres -e POSTGRES_DB=go-boilerplate postgres

# run redis
docker run -d -p 6379:6379 redis

Migration

Run below command to run migration

migrate -path migration -database "${DATABASE_URL}" up

To create a new migration file

migrate create -ext sql -dir migration -seq name

Test

Run below command to run test, and make sure that all tests are passing

go test -v ./...

Running

Run below command to run app

go run ./cmd/api/main.go

You can find usefull commands in Makefile.

Similar Resources

Golang Echo Framework

template-golang-echo Creator: 한승진 Date: 2021/10/13 Description Kubernetes-Istio 환경인 리얼패킹 클라우드에 배포하기 위한 Golang Echo 서버 기초 템플릿입니다. 배포 타겟 기술스텍 : Kubernet

Oct 13, 2021

Go REST API - Bucket list - built with go-chi, Docker, and PostgreSQL

Go REST API - Bucket list - built with go-chi, Docker, and PostgreSQL Requirements Docker and Go golang-migrate/migrate Usage Clone the repository wit

Dec 14, 2021

Quick REST API built with Go

Simple REST API built with Go # install mux router go get -u github.com/gorilla/

Jul 7, 2022

Opinionated boilerplate Golang HTTP server with CORS, OPA, Prometheus, rate-limiter for API and static website.

Opinionated boilerplate Golang HTTP server with CORS, OPA, Prometheus, rate-limiter for API and static website.

Teal.Finance/Garcon Opinionated boilerplate HTTP server with CORS, OPA, Prometheus, rate-limiter… for API and static website. Origin This library was

Nov 3, 2022

Example Golang API backend rest implementation mini project Point Of Sale using Gin Framework and Gorm ORM Database.

Example Golang API backend rest implementation mini project Point Of Sale using Gin Framework and Gorm ORM Database.

Dec 23, 2022

🍐 Elegant Golang REST API Framework

🍐 Elegant Golang REST API Framework

An Elegant Golang Web Framework Goyave is a progressive and accessible web application framework focused on REST APIs, aimed at making backend develop

Jan 9, 2023

Auth0 Middleware for go labstack/echo

go-echo-auth0-middleware Auth0 Middleware for go labstack/echo Example package main import ( "net/http" "github.com/auth0/go-jwt-middleware/v2/val

Nov 24, 2022

EchoMiddleware - Echo Middleware with golang

EchoMiddleware middleware for echo server usage import ( "github.com/universe-3

Jan 4, 2022

REST API made using native Golang libraries. This API resembles the basic working of Instagram.

REST API made using native Golang libraries. This API resembles the basic working of Instagram.

Golang RESTful API for Instagram A Go based REST API built using native libraries. The API has been thoroughly worked through with Postman. Routes inc

Mar 16, 2022
Comments
  • Add graceful Shutdown for High availability service

    Add graceful Shutdown for High availability service

    This boilerplate is very helpful for me to create go api projects without starting from scratch, but it would be nice if we implemented a graceful shutdown for the sake of the user, let's say the user is still in the middle of a request and we need to update our app or maybe our app crashes we can drain the connection first before shutting down.

    i was tried to do long live request and send interruption signal then i got an error.

    Spoiler : Screenshot 2023-01-02 at 13 10 12

    My proposal :

    adding graceful shitdown using go routine and channel just like in the echo docs https://echo.labstack.com/cookbook/graceful-shutdown/

    package main
    
    /* folded code */
    
    func main() {
          
           /* folded code */
    
           
    	// Setup route engine & middleware
    	e := echo.New()
    	e.Use(middleware.CORS())
    	e.Use(appMiddleware.RequestID())
    	e.Use(appMiddleware.Logger())
    	e.Use(middleware.Recover())
    
    	// Setup handler
    	e.GET("/swagger/*", echoSwagger.WrapHandler)
    	e.GET("/", func(c echo.Context) error {
    		return c.String(http.StatusOK, "i am alive")
    	})
    
    	httpDelivery.NewTodoHandler(e, appMiddleware, todoUC)
    	httpDelivery.NewAuthHandler(e, appMiddleware, authUC)
    
           // gracefull shutdown
           	go func() {
    		if err := e.Start(fmt.Sprintf(":%s", configApp.ServerPORT)); err != nil && err != http.ErrServerClosed {
    			e.Logger.Fatal("shutting down the server")
    		}
    	}()
    
            quit := make(chan os.Signal, 1)
    	signal.Notify(quit, os.Interrupt)
    	<-quit
    	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
    	defer cancel()
    	if err := e.Shutdown(ctx); err != nil {
    		e.Logger.Fatal(err)
    	}
    
    }
    

    it would be nice if you assign this issue to me because i'm gabut

  • openapi3 and swaggo

    openapi3 and swaggo

    I was able to get swagger docs served via echo server. One question, your jwt stuff uses uid and password for authentication. Is it possible to change to bearer auth tokens for authentication?

REST api using fiber framework written in golang and using firebase ecosystem to authentication, storage and firestore as a db and use clean architecture as base
REST api using fiber framework written in golang and using firebase ecosystem to authentication, storage and firestore as a db and use clean architecture as base

Backend API Example FiberGo Framework Docs : https://github.com/gofiber Info This application using firebase ecosystem Firebase Auth Cloud Storage Fir

May 31, 2022
A Golang restful API boilerplate based on Echo framework v4

A Golang restful API boilerplate based on Echo framework v4. Includes tools for module generation, db migration, authorization, authentication and more.

Nov 15, 2022
REST API with Echo Framework from Go
REST API with Echo Framework from Go

REST API with Echo Framework from Go

Nov 16, 2021
Best simple, lightweight, powerful and really fast Api with Golang (Fiber, REL, Dbmate) PostgreSqL Database and Clean Architecture

GOLANG FIBER API (CLEAN ARCHITECTURE) Best simple, lightweight, powerful and really fast Api with Golang (Fiber, REL, Dbmate) PostgreSqLDatabase using

Sep 2, 2022
Simple REST-API implementation using Golang with several packages (Echo, GORM) and Docker

Simple REST-API Boilerplate This is a simple implementation of REST-API using Golang and several packages (Echo and GORM). By default, I use PostgreSQ

Sep 13, 2022
REST Layer, Go (golang) REST API framework
REST Layer, Go (golang) REST API framework

REST Layer REST APIs made easy. REST Layer is an API framework heavily inspired by the excellent Python Eve. It helps you create a comprehensive, cust

Dec 16, 2022
Generate boilerplate + endpoints for Fiber REST APIs.

gomakeme Generate boilerplate + endpoints for Fiber REST APIs. Never spend 6 minutes doing something by hand when you can spend 1 week to automate it

Dec 30, 2022
Boilerplate API template includes all the common packages and setup used for API development in this Company

Boilerplate API Boilerplate API template includes all the common packages and setup used for API development in this Company. Development Copy .env.ex

Feb 19, 2022
Bootstrapper and middleware for Echo framework in golang.
Bootstrapper and middleware for Echo framework in golang.

rk-echo Interceptor & bootstrapper designed for echo framework. Currently, supports bellow functionalities. Name Description Start with YAML Start ser

Jul 9, 2022
It took me a while to figure out how I can use GraphQL with the ent ORM and serve the GraphQL endpoint via the Echo framework

Go + Graphql + Ent + Echo Boilerplate It took me a while to figure out how I can use GraphQL with the ent ORM and serve the GraphQL endpoint via the E

Sep 28, 2022