utils

package
v0.0.0-...-91c8016 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2021 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultSaltSize = 512

Variables

This section is empty.

Functions

func NewHasher

func NewHasher() *hasher

func NewJWTObj

func NewJWTObj(jwtSecretKey string) *jwtAuth

func NewMongoConnection

func NewMongoConnection(ctx context.Context, uri string) (client *mongo.Client, err error)

NewMongoConnection connect to mongodb server, returning a reusable mongo connection.

func NotFound

func NotFound(err error) bool

NotFound is shortcut for Error no documents in mongodb

func ParseKindAndBody

func ParseKindAndBody(c *gin.Context, kind string, body interface{}) error

Types

type MetaToken

type MetaToken struct {
	CredentialId string `json:"credential_id"`
	UserId       string `json:"user_id"`
	UserType     string `json:"user_type"`
	// contains filtered or unexported fields
}

func (*MetaToken) Valid

func (m *MetaToken) Valid() error

type TReqResp

type TReqResp struct {
	Kind    string      `json:"kind"`
	Success bool        `json:"success"`
	Values  interface{} `json:"values,omitempty"`
	Error   *tError     `json:"error,omitempty"`
	// contains filtered or unexported fields
}

TReqResp is a base data structure to pass request/response data

func NewReqRespStruct

func NewReqRespStruct(c *gin.Context, kind string) TReqResp

NewReqRespStruct creates TReqResp object

func (*TReqResp) BadReq

func (r *TReqResp) BadReq(message string, errRef error)

BadReq will pass the error message and error reference then wraps gin json response

func (*TReqResp) InternalErr

func (r *TReqResp) InternalErr(message string, errRef error)

InternalErr will pass the error message and error reference then wraps gin json response

func (*TReqResp) Ok

func (r *TReqResp) Ok(values interface{})

Ok will pass the value then wraps gin json response

func (*TReqResp) Unauthorized

func (r *TReqResp) Unauthorized(message string, errRef error)

Unauthorized will pass the error message then wraps gin json response

Jump to

Keyboard shortcuts

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