Categorygithub.com/spacetab-io/errors-gin-go
modulepackage
1.2.0
Repository: https://github.com/spacetab-io/errors-gin-go.git
Documentation: pkg.go.dev

# README

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/spacetab-io/errors-gin-go"
)

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 tests

# Functions

MakeResponse makes ErrorObject based on error type.
Response makes common error response.
No description provided by the author
No description provided by the author

# Variables

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Structs

No description provided by the author