mirror of
https://github.com/alibaba/higress.git
synced 2026-04-21 20:17:29 +08:00
Fix log import (#1957)
This commit is contained in:
@@ -19,12 +19,12 @@ import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"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"
|
||||
"github.com/tidwall/gjson"
|
||||
regexp "github.com/wasilibs/go-re2"
|
||||
|
||||
"github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@@ -47,7 +47,7 @@ type RequestBlockConfig struct {
|
||||
blockRegExpArray []*regexp.Regexp
|
||||
}
|
||||
|
||||
func parseConfig(json gjson.Result, config *RequestBlockConfig, log log.Log) error {
|
||||
func parseConfig(json gjson.Result, config *RequestBlockConfig, log wrapper.Log) error {
|
||||
code := json.Get("blocked_code").Int()
|
||||
if code != 0 && code > 100 && code < 600 {
|
||||
config.blockedCode = uint32(code)
|
||||
@@ -120,7 +120,7 @@ func parseConfig(json gjson.Result, config *RequestBlockConfig, log log.Log) err
|
||||
return nil
|
||||
}
|
||||
|
||||
func onHttpRequestHeaders(ctx wrapper.HttpContext, config RequestBlockConfig, log log.Log) types.Action {
|
||||
func onHttpRequestHeaders(ctx wrapper.HttpContext, config RequestBlockConfig, log wrapper.Log) types.Action {
|
||||
if len(config.blockUrls) > 0 {
|
||||
requestUrl, err := proxywasm.GetHttpRequestHeader(":path")
|
||||
if err != nil {
|
||||
@@ -176,7 +176,7 @@ func onHttpRequestHeaders(ctx wrapper.HttpContext, config RequestBlockConfig, lo
|
||||
return types.ActionContinue
|
||||
}
|
||||
|
||||
func onHttpRequestBody(ctx wrapper.HttpContext, config RequestBlockConfig, body []byte, log log.Log) types.Action {
|
||||
func onHttpRequestBody(ctx wrapper.HttpContext, config RequestBlockConfig, body []byte, log wrapper.Log) types.Action {
|
||||
log.Infof("My request-block body: %s\n", string(body))
|
||||
bodyStr := string(body)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user