paycloudhelper

package module
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2024 License: MIT Imports: 23 Imported by: 0

README

paycloudhelper

PayCloud Hub Helper Golang

Documentation

Overview

this middleware function is to revoke token jwt if status user blocked or suspend

Index

Constants

View Source
const (
	AUDITTRAIL_PROCESS = "audit-trail-process"
	AUDITTRAIL_DATA    = "audit-trail-data"
	TIME_FORMAT        = "2006-01-02 15:04:05"
)
View Source
const (
	Numeric string = "^-?[0-9]+$"
	Key     string = "^[-a-zA-Z0-9_-]+$"
)

Variables

View Source
var AppName *string
View Source
var Channel *amqp.Channel
View Source
var Que *string

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) error

func JSONEncode

func JSONEncode(obj interface{}) string

func JsonMinify

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

func LogAudittrailData

func LogAudittrailData(funcName, desc, source, commType string, key *[]string, data *RequestAndResponse)

add audittrail data

func LogAudittrailProcess

func LogAudittrailProcess(funcName, desc, info string, key *[]string)

add audittrail process

func LoggerErrorHub

func LoggerErrorHub(err interface{})

func PushMessage

func PushMessage(data interface{})

push message to audittrail queue

func ReadBody

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

read body payload and validate with the key

func RevokeToken

func RevokeToken(next echo.HandlerFunc) echo.HandlerFunc

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 AuditTrialData

type AuditTrialData struct {
	Subject           string              `json:"Subject,omitempty"`
	Function          string              `json:"Function,omitempty"`
	Description       string              `json:"Description,omitempty"`
	Key               []string            `json:"Key"`    //
	Source            string              `json:"Source"` // internal or external
	CommunicationType string              `json:"CommunicationType"`
	Data              *RequestAndResponse `json:"Data"`
}

type AuditTrialProcess

type AuditTrialProcess struct {
	Subject     string                `json:"Subject,omitempty"`
	Function    string                `json:"Function,omitempty"`
	Description string                `json:"Description,omitempty"`
	Key         []string              `json:"Key"`
	Data        DataAudittrailProcess `json:"Data"`
}

type DataAudittrailProcess

type DataAudittrailProcess struct {
	Time string `json:"Time"` // time will be handle in library
	Info string `json:"Info"` // message from service/app want to print in log
}

type Detail

type Detail struct {
	StatusCode int         `json:"StatusCode"`
	Message    string      `json:"Message"`
	Data       interface{} `json:"Data,omitempty"`
}

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 MessagePayloadAudit

type MessagePayloadAudit struct {
	Id       int         `json:"Id"`
	Command  string      `json:"Command"`
	Time     string      `json:"Time"`
	ModuleId string      `json:"ModuleId"`
	Data     interface{} `json:"Data"`
}

type RMqAutoConnect

type RMqAutoConnect struct {
	// contains filtered or unexported fields
}

func SetUpRabbitMq

func SetUpRabbitMq(host, port, vhost, username, password, audittrailQue, appName string) RMqAutoConnect

service must call this func in main function

func (*RMqAutoConnect) CloseConnection

func (r *RMqAutoConnect) CloseConnection()

service must call this method in defer func

type Request

type Request struct {
	Time        string      `json:"Time"`
	Path        string      `json:"Path,omitempty"`
	QueryString interface{} `json:"QueryString,omitempty"`
	Header      interface{} `json:"Header,omitempty"`
	Param       interface{} `json:"Param,omitempty"`
	Body        interface{} `json:"Body,omitempty"`
	IpAddress   string      `json:"IpAddress,omitempty"`
	BrowserId   int         `json:"BrowserId,omitempty"`
	Latitude    string      `json:"Latitude,omitempty"`
	Longitude   string      `json:"Longitude,omitempty"`
}

type RequestAndResponse

type RequestAndResponse struct {
	Request  Request       `json:"Request"`
	Response ResponseAudit `json:"Response"`
}

type ResponseApi

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

func (*ResponseApi) Accepted

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

in process response

func (*ResponseApi) BadRequest

func (r *ResponseApi) BadRequest(message string, intenalCode string)

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, internalCode string, status string, data interface{})

func (*ResponseApi) Success

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

func (*ResponseApi) Unauthorized

func (r *ResponseApi) Unauthorized(message string, intenalCode string)

unauthorized user

type ResponseAudit

type ResponseAudit struct {
	Time   string `json:"Time"`
	Detail Detail `json:"Detail,omitempty"`
}

Jump to

Keyboard shortcuts

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