Documentation
¶
Index ¶
- func ContextWithRequest(ctx context.Context, req *Request) context.Context
- func ContextWithRequestType(ctx context.Context, reqType RequestType) context.Context
- func Init() error
- func LogPartnerRequest(log *PartnerRequest)
- func LogRequest(log *Request)
- func LogUltronEx(msg *UltronExMsg)
- func RedactJSON(json, replacement string, keys [][]string) string
- func RedactXML(xml, replacement string, tags []string) string
- func Sync()
- type Headers
- type PartnerRequest
- type Request
- type RequestType
- type UltronExMsg
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContextWithRequest ¶
ContextWithRequest returns a new context from a parent context with request added into it
func ContextWithRequestType ¶
func ContextWithRequestType(ctx context.Context, reqType RequestType) context.Context
ContextWithRequestType returns a new context from a parent context with request type added into it
func LogPartnerRequest ¶
func LogPartnerRequest(log *PartnerRequest)
LogPartnerRequest logs a partner request to local file
func RedactJSON ¶
RedactJSON replaces value of key paths from the input JSON with replacement or defaultReplacement when replacement is empty
Example:
input = `
{
"first": "first value",
"second": {
"first": "1st of second",
"second": "2nd of second",
"third": {
"first": "1st of second third",
"second": "2nd of second third",
"third": "3rd of second third",
}
}
}`
keys := [][]string{{"first"}, {"second", "second"}, {"second", "third", "first"}}
RedactJSON(input, "Wego", keys) will return
{
"first": "Wego",
"second": {
"first": "1st of second",
"second": "Wego",
"third": {
"first": "Wego",
"second": "2nd of second third",
"third": "3rd of second third",
}
}
}
Types ¶
type Headers ¶
Headers ...
func (Headers) MarshalLogArray ¶
func (h Headers) MarshalLogArray(enc zapcore.ArrayEncoder) error
MarshalLogArray marshal Headers to zap log array Need to implement this to log it with zap.Array
type PartnerRequest ¶
PartnerRequest contains information of requests we sent to our partners
type Request ¶
type Request struct {
Type RequestType
PaymentRef string
DeploymentRef string
ClientCode string
TransactionRef string
Method string
URL string
RequestHeaders Headers
RequestBody string
IP string
StatusCode int32
ResponseHeaders Headers
ResponseBody string
RequestedAt time.Time
Duration time.Duration
Error error
}
Request contains general information of a request
func RequestFromContext ¶
RequestFromContext gets the request from context
type RequestType ¶
type RequestType string
RequestType ...
const ( RequestTypeValidateOrder RequestType = "ValidateOrder" RequestTypeUpdatePostAuthResult RequestType = "UpdatePostAuthResult" RequestTypeCompleteOrder RequestType = "CompleteOrder" RequestTypeCancelOrderByCustomer RequestType = "CancelOrderByCustomer" RequestTypeCancelOrderByMerchant RequestType = "CancelOrderByMerchant" RequestTypeClaimChargeback RequestType = "ClaimChargeback" RequestTypeFetchAccessToken RequestType = "FetchAccessToken" RequestTypeGetPaymentOptions RequestType = "GetPaymentOptions" RequestTypeAuthorizePayment RequestType = "AuthorizePayment" RequestTypeVoidPayment RequestType = "VoidPayment" RequestTypeCapturePayment RequestType = "CapturePayment" RequestTypeRefundPayment RequestType = "RefundPayment" RequestTypeGetPaymentDetails RequestType = "GetPaymentDetails" RequestTypeGetPaymentActions RequestType = "GetPaymentActions" RequestTypeGetDisputes RequestType = "GetDisputes" RequestTypeProcessDisputes RequestType = "ProcessDisputes" RequestTypeGetDisputeDetails RequestType = "GetDisputeDetails" RequestTypeQueryBIN RequestType = "QueryBIN" RequestTypeRequestToken RequestType = "RequestToken" RequestTypeRedirectPost3DS RequestType = "RedirectPost3DS" RequestTypeProcessPendingPayments RequestType = "ProcessPendingPayments" RequestTypeDeployVirtualCard RequestType = "DeployVirtualCard" RequestTypeUpdateVirtualCardDeployment RequestType = "UpdateVirtualCardDeployment" RequestTypeGetVirtualCardDeploymentDetails RequestType = "GetVirtualCardDeploymentDetails" RequestTypeGetVirtualCardActivities RequestType = "GetVirtualCardActivities" RequestTypeCancelVirtualCardDeployment RequestType = "CancelVirtualCardDeployment" RequestTypeGetCardDetailsPublic RequestType = "GetCardDetailsPublic" RequestTypeGetCardDetails RequestType = "GetCardDetails" RequestTypeSendDisputeEvent RequestType = "SendDisputeEvent" RequestTypeSendPaymentEvent RequestType = "SendPaymentEvent" RequestTypeUnknown RequestType = "Unknown" )
PartnerRequestType list
func RequestTypeFromContext ¶
func RequestTypeFromContext(ctx context.Context) (reqType RequestType)
RequestTypeFromContext gets the request type from context
type UltronExMsg ¶
UltronExMsg ...
func (UltronExMsg) MarshalLogObject ¶
func (um UltronExMsg) MarshalLogObject(enc zapcore.ObjectEncoder) error
MarshalLogObject marshal UltronExMsg to zap log object The struct need to implement this, so we can log it with zap.Object