Skip to content
This repository has been archived by the owner on May 19, 2020. It is now read-only.

microparts/errors-go-gin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ginerrors

Smart generating error code and response for gin mux based on passed error.

Usage

package main

import (
	"errors"
	"net/http"
	
	"github.com/gin-gonic/gin"
	"github.com/microparts/errors-go-gin"
)

func main() {
	r := gin.New()

	r.GET("/", func(c*gin.Context) {c.JSON(http.StatusOK,`{"status":"ok"}`)})
	r.GET("/err", func(c *gin.Context) { ginerrors.Response(c, errors.New("error")) })
	_ = r.Run(":8080")
}

Linter

Lint code with golangci-lint and custom config for it:

make lint

Testing

Test code with race checking and generation coverage profile:

make test