mirror of
https://github.com/alibaba/higress.git
synced 2026-06-06 19:27:33 +08:00
optimize plugin sdk (#1930)
This commit is contained in:
@@ -20,6 +20,7 @@ import (
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
||||
"github.com/alibaba/higress/plugins/wasm-go/pkg/log"
|
||||
"github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper"
|
||||
"github.com/higress-group/proxy-wasm-go-sdk/proxywasm"
|
||||
"github.com/higress-group/proxy-wasm-go-sdk/proxywasm/types"
|
||||
@@ -127,7 +128,7 @@ type KeyAuthConfig struct {
|
||||
credential2Name map[string]string `yaml:"-"`
|
||||
}
|
||||
|
||||
func parseGlobalConfig(json gjson.Result, global *KeyAuthConfig, log wrapper.Log) error {
|
||||
func parseGlobalConfig(json gjson.Result, global *KeyAuthConfig, log log.Log) error {
|
||||
log.Debug("global config")
|
||||
|
||||
// init
|
||||
@@ -200,7 +201,7 @@ func parseGlobalConfig(json gjson.Result, global *KeyAuthConfig, log wrapper.Log
|
||||
return nil
|
||||
}
|
||||
|
||||
func parseOverrideRuleConfig(json gjson.Result, global KeyAuthConfig, config *KeyAuthConfig, log wrapper.Log) error {
|
||||
func parseOverrideRuleConfig(json gjson.Result, global KeyAuthConfig, config *KeyAuthConfig, log log.Log) error {
|
||||
log.Debug("domain/route config")
|
||||
|
||||
*config = global
|
||||
@@ -233,7 +234,7 @@ func parseOverrideRuleConfig(json gjson.Result, global KeyAuthConfig, config *Ke
|
||||
// - global_auth 未设置:
|
||||
// - 若没有一个 domain/route 配置该插件:则遵循 (1*)
|
||||
// - 若有至少一个 domain/route 配置该插件:则遵循 (2*)
|
||||
func onHttpRequestHeaders(ctx wrapper.HttpContext, config KeyAuthConfig, log wrapper.Log) types.Action {
|
||||
func onHttpRequestHeaders(ctx wrapper.HttpContext, config KeyAuthConfig, log log.Log) types.Action {
|
||||
var (
|
||||
noAllow = len(config.allow) == 0 // 未配置 allow 列表,表示插件在该 domain/route 未生效
|
||||
globalAuthNoSet = config.globalAuth == nil
|
||||
|
||||
Reference in New Issue
Block a user