完善商福通接口通知字段;提供一个环境变量以决定是否打印原始 http 报文

This commit is contained in:
2025-06-23 11:27:28 +08:00
parent 546e81fee3
commit fda1a2de0e
2 changed files with 45 additions and 9 deletions

30
pkg/env/env.go vendored
View File

@@ -148,7 +148,8 @@ func loadRedis() {
// region log
var (
LogLevel = slog.LevelDebug
LogLevel = slog.LevelDebug
LogHttpDump = false // 是否打印HTTP请求和响应的原始数据
)
func loadLog() {
@@ -163,6 +164,17 @@ func loadLog() {
case "error":
LogLevel = slog.LevelError
}
_LogHttpDump := os.Getenv("LOG_HTTP_DUMP")
if _LogHttpDump != "" {
value, err := strconv.ParseBool(_LogHttpDump)
if err != nil {
panic("环境变量 LOG_HTTP_DUMP 的值不是布尔值")
}
LogHttpDump = value
} else {
LogHttpDump = false // 默认不打印HTTP请求和响应的原始数据
}
}
// endregion
@@ -355,6 +367,8 @@ var (
SftPayRouteId string
SftPayAppPrivateKey string
SftPayPublicKey string
SftReturnUrl *string
SftNotifyUrl *string
)
func loadSftPay() {
@@ -394,6 +408,20 @@ func loadSftPay() {
} else {
SftPayPublicKey = value
}
value = os.Getenv("SFTPAY_RETURN_URL")
if value != "" {
SftReturnUrl = &value
} else {
SftReturnUrl = nil
}
value = os.Getenv("SFTPAY_NOTIFY_URL")
if value != "" {
SftNotifyUrl = &value
} else {
SftNotifyUrl = nil
}
}
// endregion