common

package
v0.0.0-...-8f6ea6c Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2022 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BadRequestErrorCode    = "400001"
	ForbiddenErrorCode     = "403001"
	NotFoundsErrorCode     = "404001"
	BadBodyErrorCode       = "422001"
	AlreadyExistsErrorCode = "422002"
)
View Source
const AccessObjectCollection string = "access_object"
View Source
const AccessTokensCollection string = "access_tokens"
View Source
const ProvidersCollection string = "providers"

Variables

View Source
var MongoClient *mongo.Database

Functions

func GetMongoClient

func GetMongoClient() *mongo.Database

Using this function to get a connection, you can create your connection pool here.

func GetTranslator

func GetTranslator() *ut.Translator

func HexToPrimitiveIdRef

func HexToPrimitiveIdRef(idHex string) primitive.ObjectID

func LoadMongoClient

func LoadMongoClient()

func RegisterValidator

func RegisterValidator(validatorFn validator.Func, name string, errText string)

Types

type CommonError

type CommonError struct {
	Errors map[string]interface{} `json:"errors"`
}

func NewError

func NewError(key string, err error) CommonError

func NewValidatorError

func NewValidatorError(key string, errs validator.ValidationErrors) CommonError

To handle the error returned by c.Bind in gin framework https://github.com/go-playground/validator/blob/v9/_examples/translations/main.go

Jump to

Keyboard shortcuts

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