utils

package
v0.7.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 1, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bind

func Bind(c *gin.Context, obj interface{}) error

Changed the c.MustBindWith() -> c.ShouldBindWith(). I don't want to auto return 400 when error happened. origin function is here: https://github.com/gin-gonic/gin/blob/master/context.go

func GenAuthTokens

func GenAuthTokens(id uint) (string, string)

func GenRandomString

func GenRandomString(length int) string

func SetupValidatorOptions

func SetupValidatorOptions()

Types

type CommonError

type CommonError struct {
	StatusCode  int    `json:"-"`
	Message     string `json:"message"`
	Description string `json:"description,omitempty"`
}

func NewError

func NewError(statusCode int, errMsg string, descriptionStrings ...string) *CommonError

func (*CommonError) Error

func (ce *CommonError) Error() string

func (*CommonError) H

func (ce *CommonError) H() (int, *CommonError)

type CommonValidationError

type CommonValidationError struct {
	Errors map[string]string `json:"validation-errors"`
}

func NewValidatorError

func NewValidatorError(err error) CommonValidationError

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL