Documentation
¶
Index ¶
- Constants
- Variables
- func AddValidatorLibs()
- func DeleteRedis(id string) (err error)
- func GetRedis(id string) (result string, err error)
- func GetRedisClient(redisHost, redisPort, redisPassword string, redisDb int) (*redis.Client, error)
- func InitLogger()
- func InitRedis(ctx context.Context, opt *redis.Options) (*redis.Client, error)
- func JSONEncode(obj interface{}) string
- func JSONMarshalNoEsc(t interface{}) ([]byte, error)
- func JsonMinify(jsonB []byte) ([]byte, error)
- func LoggerErrorHub(err interface{})
- func ReadBody(c echo.Context, idem string) (map[string]interface{}, string, error)
- func StoreRedis(id string, data interface{}, duration time.Duration) (err error)
- func VerifCsrf(next echo.HandlerFunc) echo.HandlerFunc
- func VerifIdemKey(next echo.HandlerFunc) echo.HandlerFunc
- func VerifyMD5(idemKey string, request []byte) (string, error)
- type Headers
- type Logger
- type ResponseApi
- func (r *ResponseApi) Accepted(data interface{})
- func (r *ResponseApi) BadRequest(message string, err interface{})
- func (r *ResponseApi) InternalServerError(err error)
- func (r *ResponseApi) Out(code int, message, status string, data interface{})
- func (r *ResponseApi) Success(message string, data interface{})
- func (r *ResponseApi) Unauthorized(message string)
Constants ¶
View Source
const ( CONFIG_PARTNERS = "config_partners" CONFIG_PAYMENT_METHODS = "config_payment_methods" )
View Source
const ( // Localize log levels from zerolog LevelDebug = level(zerolog.DebugLevel) LevelInfo = level(zerolog.InfoLevel) LevelWarn = level(zerolog.WarnLevel) LevelError = level(zerolog.ErrorLevel) LevelFatal = level(zerolog.FatalLevel) )
View Source
const ( Numeric string = "^-?[0-9]+$" Key string = "^[-a-zA-Z0-9_-]+$" )
Variables ¶
View Source
var ( RedisPoolClient *redis.Client RedisDefaultDuration = 180 * time.Second )
Functions ¶
func AddValidatorLibs ¶
func AddValidatorLibs()
func DeleteRedis ¶
func GetRedisClient ¶
func InitLogger ¶
func InitLogger()
func JSONEncode ¶
func JSONEncode(obj interface{}) string
func JSONMarshalNoEsc ¶
func JsonMinify ¶
func LoggerErrorHub ¶
func LoggerErrorHub(err interface{})
func VerifIdemKey ¶
func VerifIdemKey(next echo.HandlerFunc) echo.HandlerFunc
Types ¶
type Headers ¶
type Headers struct { IdempotencyKey string `json:"idem_key"` Session string `json:"session"` Csrf string `json:"csrf"` }
func (*Headers) ValidateHeaderCsrf ¶
func (h *Headers) ValidateHeaderCsrf() interface{}
func (*Headers) ValidateHeaderIdem ¶
func (h *Headers) ValidateHeaderIdem() interface{}
type Logger ¶
type Logger interface { Debug() *zerolog.Event Info() *zerolog.Event Warn() *zerolog.Event Error() *zerolog.Event Fatal() *zerolog.Event With() zerolog.Context }
Logger has selective logger method signatures
func FromContext ¶
FromContext retrives the logger from context. In absence of logger in context, this creates a new logger with Stdout as output stream and default log level specified in constants.
func FromRawLogger ¶
FromRawLogger creates Logger type from zerolog Logger
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)
Click to show internal directories.
Click to hide internal directories.