diff --git a/go.mod b/go.mod index 1ec307d..11818ec 100644 --- a/go.mod +++ b/go.mod @@ -2,4 +2,4 @@ module github.com/packruler/traefik-themepark go 1.16 -require github.com/packruler/rewrite-body v1.1.2 +require github.com/packruler/rewrite-body v1.2.0 diff --git a/go.sum b/go.sum index 1457abf..1d712e0 100644 --- a/go.sum +++ b/go.sum @@ -1,2 +1,2 @@ -github.com/packruler/rewrite-body v1.1.2 h1:2HJZ3hU4UAy/0ZVKsu0xzQTO62rVGWGDzVtea4D1OY0= -github.com/packruler/rewrite-body v1.1.2/go.mod h1:GZ5+jy2LT3PEMAwN15ia+/7+ltBFhY/Sc7d1nRuPxbw= +github.com/packruler/rewrite-body v1.2.0 h1:bOud6QkhXeJvtJVbU2L5XnPwLJD8WhkT9wlQ1K6kC1Y= +github.com/packruler/rewrite-body v1.2.0/go.mod h1:GZ5+jy2LT3PEMAwN15ia+/7+ltBFhY/Sc7d1nRuPxbw= diff --git a/vendor/github.com/packruler/rewrite-body/handler/handler.go b/vendor/github.com/packruler/rewrite-body/handler/handler.go index ad29796..8aa24a7 100644 --- a/vendor/github.com/packruler/rewrite-body/handler/handler.go +++ b/vendor/github.com/packruler/rewrite-body/handler/handler.go @@ -3,6 +3,7 @@ package handler import ( "context" + "encoding/json" "errors" "fmt" "net/http" @@ -40,6 +41,7 @@ func New(_ context.Context, next http.Handler, config *Config, name string) (htt logWriter := *logger.CreateLogger(logger.LogLevel(config.LogLevel)) config.Monitoring.EnsureDefaults() + config.Monitoring.EnsureProperFormat() result := &rewriteBody{ name: name, @@ -50,6 +52,10 @@ func New(_ context.Context, next http.Handler, config *Config, name string) (htt monitoringConfig: config.Monitoring, } + data, _ := json.Marshal(config) + + logWriter.LogDebugf("Initial config: %v", string(data)) + return result, nil } diff --git a/vendor/github.com/packruler/rewrite-body/httputil/monitoring_config.go b/vendor/github.com/packruler/rewrite-body/httputil/monitoring_config.go index 18ebea5..8ff1dde 100644 --- a/vendor/github.com/packruler/rewrite-body/httputil/monitoring_config.go +++ b/vendor/github.com/packruler/rewrite-body/httputil/monitoring_config.go @@ -1,6 +1,9 @@ package httputil -import "net/http" +import ( + "net/http" + "strings" +) // MonitoringConfig structure of data for handling configuration for // controlling what content is monitored. @@ -19,3 +22,14 @@ func (config *MonitoringConfig) EnsureDefaults() { config.Types = []string{"text/html"} } } + +// EnsureProperFormat handle weird yaml parsing until the underlying issue can be resolved. +func (config *MonitoringConfig) EnsureProperFormat() { + if len(config.Methods) == 1 && strings.HasPrefix(config.Methods[0], "║24║") { + config.Methods = strings.Split(strings.ReplaceAll(config.Methods[0], "║24║", ""), "║") + } + + if len(config.Types) == 1 && strings.HasPrefix(config.Types[0], "║24║") { + config.Types = strings.Split(strings.ReplaceAll(config.Types[0], "║24║", ""), "║") + } +} diff --git a/vendor/modules.txt b/vendor/modules.txt index aeecb46..a08d439 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1,4 +1,4 @@ -# github.com/packruler/rewrite-body v1.1.2 +# github.com/packruler/rewrite-body v1.2.0 ## explicit github.com/packruler/rewrite-body/compressutil github.com/packruler/rewrite-body/handler