Skip to content

Commit

Permalink
feat: 支持 HTTP 消息推送配置
Browse files Browse the repository at this point in the history
  • Loading branch information
rehiy committed Mar 2, 2024
1 parent db93d3c commit 8d67bc2
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
7 changes: 4 additions & 3 deletions args/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package args
// 日志配置

type ILog struct {
Dir string `yaml:"Dir"` // 日志目录
Level string `yaml:"Level"` // 日志级别 debug|info|warn|error
Target string `yaml:"Target"` // 日志输出方式 both|file|null|stdout|stderr
Dir string `yaml:"Dir"` // 存储目录
Level string `yaml:"Level"` // 记录级别 debug|info|warn|error
Target string `yaml:"Target"` // 输出方式 both|file|null|stdout|stderr
}

var Log = &ILog{
Expand Down Expand Up @@ -35,6 +35,7 @@ type IWeb struct {
Address string `yaml:"Address"` // Web 监听地址
Swagger bool `yaml:"Swagger"` // 是否启用 Api 文档
Token string `yaml:"Token"` // 使用 Token 验证请求
Webhook string `yaml:"Webhook"` // 消息推送地址
}

var Web = &IWeb{
Expand Down
7 changes: 4 additions & 3 deletions config.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# 运行日志
Log:
Dir: logs # 日志存储目录
Level: info # 日志级别,debug|info|warn|error
Target: stdout # 日志输出方式,both|file|null|stdout|stderr
Dir: logs # 存储目录
Level: info # 记录级别,debug|info|warn|error
Target: stdout # 输出方式,both|file|null|stdout|stderr

# Wcf 服务
Wcf:
Expand All @@ -17,3 +17,4 @@ Web:
Address: 127.0.0.1:7600 # 监听地址
Swagger: true # 是否启用 Api 在线文档
Token: "" # 使用 Token 验证请求,留空则不验证
Webhook: "" # 消息推送地址,留空则不启用
11 changes: 11 additions & 0 deletions httpd/wcfrest/router.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package wcfrest

import (
"strings"

"github.com/opentdp/go-helper/httpd"

"github.com/opentdp/wechat-rest/args"
"github.com/opentdp/wechat-rest/httpd/midware"
"github.com/opentdp/wechat-rest/wclient"
)
Expand Down Expand Up @@ -57,4 +60,12 @@ func Route() {

rg.GET("socket_receiver", ctrl.socketReceiver)

// 启用 HTTP 消息推送

if args.Web.Webhook != "" {
for _, url := range strings.Split(args.Web.Webhook, ",") {
ctrl.enableUrlReceiver(url)
}
}

}

0 comments on commit 8d67bc2

Please sign in to comment.