mirror of
https://github.com/haowanxing/plugin-http-auth.git
synced 2025-12-24 10:30:58 +08:00
35 lines
827 B
Go
35 lines
827 B
Go
package http_auth
|
|
|
|
import (
|
|
"go.uber.org/zap"
|
|
. "m7s.live/engine/v4"
|
|
"m7s.live/engine/v4/config"
|
|
)
|
|
|
|
type req struct {
|
|
Action string `json:"action"`
|
|
App string `json:"app"`
|
|
Stream string `json:"stream"`
|
|
Param string `json:"param"`
|
|
ClientID string `json:"client_id"`
|
|
}
|
|
|
|
type HttpAuthConfig struct {
|
|
OnPubAddr string
|
|
OnSubAddr string
|
|
}
|
|
|
|
func (p *HttpAuthConfig) OnEvent(event any) {
|
|
switch e := event.(type) {
|
|
case FirstConfig: //插件初始化逻辑
|
|
plugin.Info("Config", zap.String("OnSubAddr", p.OnSubAddr))
|
|
plugin.Info("Config", zap.String("OnPubAddr", p.OnPubAddr))
|
|
p.changeAuthHook()
|
|
case config.Config: //插件热更新逻辑
|
|
p.OnPubAddr = e.Get("onpubaddr").GetValue().(string)
|
|
p.OnSubAddr = e.Get("onsubaddr").GetValue().(string)
|
|
}
|
|
}
|
|
|
|
var plugin = InstallPlugin(new(HttpAuthConfig))
|