Documentation ¶
Index ¶
- Constants
- Variables
- func BHLog(in interface{}) interface{}
- func GenerateKCV(key []byte) string
- func GenerateKCVByte(key []byte, calcSize int) []byte
- func GetFileAndLine() string
- func GorillaLoggingHandler(router *mux.Router) http.Handler
- func LoadErrorMap(errMap map[ErrorCode]ErrorData)
- func LogCritical(format string, args ...interface{})
- func LogDebug(format string, args ...interface{})
- func LogError(format string, args ...interface{})
- func LogFilter(in interface{}) string
- func LogInfo(format string, args ...interface{})
- func LogWarning(format string, args ...interface{})
- func LoggingHandler(router *http.ServeMux) http.Handler
- func MaskCVV(cvv string) string
- func MaskDate(date string) string
- func MaskName(inData string) string
- func MaskPan(inData string) string
- func MaskPhone(inData string) string
- func PingHandler(w http.ResponseWriter, r *http.Request)
- func ZeroPadding(ciphertext []byte, blockSize int) []byte
- type BaseErrorType
- type DefaultResp
- type EnvConfigMap
- type ErrorCode
- type ErrorData
- type ErrorTypeEnum
- type LocalizedErrorData
- type Options
- type PingResp
- type ReqInfo
- func (r *ReqInfo) HttpReq(rd RequestData) *BaseErrorType
- func (r *ReqInfo) LogCritical(format string, args ...interface{})
- func (r *ReqInfo) LogDebug(format string, args ...interface{})
- func (r *ReqInfo) LogError(format string, args ...interface{})
- func (r *ReqInfo) LogInfo(format string, args ...interface{})
- func (r *ReqInfo) LogWarning(format string, args ...interface{})
- func (r *ReqInfo) ReqInfoFill(req *http.Request)
- func (r *ReqInfo) ReqInfoGenerate()
- func (r *ReqInfo) RequestId() string
- func (r *ReqInfo) RespGZipJson(w http.ResponseWriter, data interface{})
- func (r *ReqInfo) RespJson(w http.ResponseWriter, data interface{})
- type RequestData
Constants ¶
View Source
const DateTime = "2006-01-02 15:04:05"
View Source
const KeyRequestId = "Request-Id"
View Source
const KeyTerminalId = "Terminal-Id"
View Source
const RemoteDefaultReadTimeout = 40 * time.Second
Variables ¶
View Source
var ConfigMapKeys []EnvConfigMap
View Source
var ConfigMapValues = map[EnvConfigMap]string{}
View Source
var ErrorTypeNames = []string{
"Undefined",
"User",
"Hardware",
"Technical",
"Internal",
"Network",
"Parameter",
"Host",
"Protocol",
}
View Source
var GlBuildDate string
View Source
var GlErrorDataMap = map[ErrorCode]ErrorData{ ErrCodeAuth: {"Authentication Failed", ErrorTypeInternal}, ErrCodeBadData: {"Bad Data %s", ErrorTypeParameter}, ErrCodeServer: {"Server Error %s", ErrorTypeTechnical}, ErrCodeConnection: {"Connection Failure %s", ErrorTypeNetwork}, ErrCodeNotFound: {"Not Found %s", ErrorTypeTechnical}, ErrCodeConfig: {"Config Error %s", ErrorTypeTechnical}, }
View Source
var GlHeaders = []string{ KeyRequestId, "Device-Id", "Operation-Id", "Signature", "Device-Model", "Device-Os", "Platform", "X-Real-Ip", "User-Agent", "Cipher-V", "Request-T", KeyTerminalId, "Term-App-Name", "Model", "terminalModel", "pos_firmware", "Terminal-Datetime", "Remote-Addr", "Program-Name", "App-build", "Manufacturer", "Request-t", "X-Request-Id", "Accept-Language", "Accept-Charset", "Authorization", "Content-Type", "application", "Brc", "Username", "Password", "ProviderIg", "Providerpwd", "Userlanguage", "Userid", "Reader-Id", }
View Source
var GlHostName string
View Source
var GlProcessName string
View Source
var GlRedisClient *redis.Client
View Source
var GlRunMode string
View Source
var GlVersion string
View Source
var GlogWriter *gelf.Writer
View Source
var HeadersForTrace = []string{
"X-Request-Id",
"X-B3-Traceid",
"X-Ot-Span-Context",
}
Functions ¶
func BHLog ¶
func BHLog(in interface{}) interface{}
BHLog : BoobHolder, BloodyHell, BrokenHearted, BountyHunter, BlackHole,
func GenerateKCV ¶ added in v0.0.10
func GenerateKCVByte ¶ added in v0.0.10
func GetFileAndLine ¶ added in v0.0.8
func GetFileAndLine() string
func GorillaLoggingHandler ¶ added in v0.0.13
func LoadErrorMap ¶ added in v0.0.5
func LogCritical ¶
func LogCritical(format string, args ...interface{})
func LogWarning ¶
func LogWarning(format string, args ...interface{})
func MaskDate ¶
MaskDate
06/23 2023-06 2016-02-24T00:30-0800 2009-06-15T13:45:30 2009-06-15T13:45:30.0000000 2009-06-15T13:45:30.0000000Z Mon, 15 Jun 2009 20:45:30 GMT
func PingHandler ¶ added in v0.0.7
func PingHandler(w http.ResponseWriter, r *http.Request)
func ZeroPadding ¶ added in v0.0.10
ZeroPadding :
Types ¶
type BaseErrorType ¶
type BaseErrorType struct { Code ErrorCode `json:"code"` Message string `json:"message"` Module string `json:"module"` FormError interface{} `json:"form_error"` Level ErrorTypeEnum `json:"level"` }
func HttpRequester ¶
func HttpRequester(rd RequestData, log *strings.Builder) *BaseErrorType
func NewErrorByCode ¶
func NewErrorByCode(code ErrorCode, a ...interface{}) *BaseErrorType
func TripleDesDecrypt ¶ added in v0.0.10
func TripleDesDecrypt(ede2Key []byte, src []byte) ([]byte, *BaseErrorType)
func TripleDesEncrypt ¶ added in v0.0.10
func TripleDesEncrypt(ede2Key []byte, src []byte) ([]byte, *BaseErrorType)
TripleDesEncrypt :
type DefaultResp ¶ added in v0.0.7
type EnvConfigMap ¶
type EnvConfigMap string
type ErrorData ¶
type ErrorData struct { Message string Level ErrorTypeEnum }
type ErrorTypeEnum ¶
type ErrorTypeEnum int
const ( ErrorTypeUndefined ErrorTypeEnum = iota ErrorTypeUser ErrorTypeHardware ErrorTypeTechnical ErrorTypeInternal ErrorTypeNetwork ErrorTypeParameter ErrorTypeHost ErrorTypeProtocol )
type LocalizedErrorData ¶
type LocalizedErrorData struct { MessageMN string MessageEN string ErrType ErrorTypeEnum }
type Options ¶
type Options struct { ProcessName string ConfMapKeyGrayLog EnvConfigMap ConfMapKeyRedisDB EnvConfigMap ConfigMapKeyRedisAddr EnvConfigMap ConfigMapKeyRedisPrefix EnvConfigMap ConfigMapKeys []EnvConfigMap ConfigMapValues map[EnvConfigMap]string BaseErrorMap *map[ErrorCode]ErrorData LocalizedErrorMap *map[string]LocalizedErrorData LogHeaders []string ConfigRabbitHost string ConfigRabbitQueue string }
var GlOption *Options
type PingResp ¶ added in v0.0.7
type PingResp struct { DefaultResp Ret struct { ResponseCode string `json:"response_code,omitempty"` ResponseMsg string `json:"response_msg,omitempty"` BuildDate string `json:"build_date"` ServiceName string `json:"service_name,omitempty"` Version string `json:"version"` RunMode string `json:"run_mode"` StartTime time.Time `json:"start_time,omitempty"` Info string `json:"info,omitempty"` } `json:"ret,omitempty"` }
type ReqInfo ¶
type ReqInfo struct { Req *http.Request `json:"-"` RequestHeads map[string]string `json:"headers,omitempty"` StartTime time.Time `json:"-"` Log *strings.Builder `json:"-"` Context context.Context `json:"-"` LocaleCode string `json:"locale"` }
func (*ReqInfo) HttpReq ¶
func (r *ReqInfo) HttpReq(rd RequestData) *BaseErrorType
func (*ReqInfo) LogCritical ¶
func (*ReqInfo) LogWarning ¶
func (*ReqInfo) ReqInfoFill ¶
func (*ReqInfo) ReqInfoGenerate ¶
func (r *ReqInfo) ReqInfoGenerate()
func (*ReqInfo) RespGZipJson ¶ added in v0.0.15
func (r *ReqInfo) RespGZipJson(w http.ResponseWriter, data interface{})
func (*ReqInfo) RespJson ¶ added in v0.0.15
func (r *ReqInfo) RespJson(w http.ResponseWriter, data interface{})
type RequestData ¶
type RequestData struct { Req *http.Request ReqInfo *ReqInfo ReqAddr *EnvConfigMap ReqPath string Timeout *time.Duration FullURL string Method string ReqByte []byte RespByte []byte FormData map[string]string Body interface{} Resp interface{} RespText *strings.Builder Client *http.Client CustomHeader *http.Header }
Source Files ¶
Click to show internal directories.
Click to hide internal directories.