qoingohelper

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2023 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Numeric string = "^-?[0-9]+$"
	Key     string = "^[-a-zA-Z0-9_-]+$"
)

Variables

View Source
var RedisPoolClient *redis.Client

Functions

func AddValidatorLibs

func AddValidatorLibs()

func DeleteRedis

func DeleteRedis(id string) (err error)

func GetRedis

func GetRedis(id string) (result string, err error)

func GetRedisClient

func GetRedisClient(redisHost, redisPort, redisPassword string, redisDb int) (*redis.Client, error)

func JSONEncode

func JSONEncode(obj interface{}) string

func JSONMarshalNoEsc

func JSONMarshalNoEsc(t interface{}) ([]byte, error)

func JsonMinify

func JsonMinify(jsonB []byte) ([]byte, error)

func LoggerErrorHub

func LoggerErrorHub(err interface{})

func ReadBody

func ReadBody(c echo.Context, idem string) (map[string]interface{}, string, error)

read body payload and validate with the key

func StoreRedis

func StoreRedis(id string, data interface{}, duration time.Duration) (err error)

func VerifCsrf

func VerifCsrf(next echo.HandlerFunc) echo.HandlerFunc

func VerifIdemKey

func VerifIdemKey(next echo.HandlerFunc) echo.HandlerFunc

func VerifyMD5

func VerifyMD5(idemKey string, request []byte) (string, error)

generate md5 hash and compare the result with current key submitted

Types

type Headers

type Headers struct {
	IdempotencyKey string `json:"idem_key"`
	Session        string `json:"session"`
	Csrf           string `json:"csrf"`
}

func (*Headers) ValiadateHeaderCsrf

func (h *Headers) ValiadateHeaderCsrf() interface{}

func (*Headers) ValiadateHeaderIdem

func (h *Headers) ValiadateHeaderIdem() interface{}

type ResponseApi

type ResponseApi struct {
	Code    int         `json:"code"`
	Status  string      `json:"status"`
	Message string      `json:"message"`
	Data    interface{} `json:"data,omitempty"`
}

func (*ResponseApi) Accepted

func (r *ResponseApi) Accepted(data interface{})

func (*ResponseApi) BadRequest

func (r *ResponseApi) BadRequest(message string, err interface{})

BadRequest is method for bad request

func (*ResponseApi) InternalServerError

func (r *ResponseApi) InternalServerError(err error)

InternalServerError is method for internal server error

func (*ResponseApi) Out

func (r *ResponseApi) Out(code int, message, status string, data interface{})

func (*ResponseApi) Success

func (r *ResponseApi) Success(message string, data interface{})

func (*ResponseApi) Unauthorized

func (r *ResponseApi) Unauthorized(message string)

Jump to

Keyboard shortcuts

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