From 719fce386e350029a3581e8b16617c96c0734a29 Mon Sep 17 00:00:00 2001 From: githubsands Date: Wed, 10 Oct 2018 16:51:42 -0700 Subject: [PATCH] Log specified headers --- petasos.spec | 2 ++ src/petasos/petasos.go | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/petasos.spec b/petasos.spec index cddd350..2a21aa1 100644 --- a/petasos.spec +++ b/petasos.spec @@ -109,3 +109,5 @@ if [ $1 = 0 ]; then fi %changelog +* Tue Mar 28 2017 Weston Schmidt - 0.1.1 +- initial creation diff --git a/src/petasos/petasos.go b/src/petasos/petasos.go index 390e34c..0a80a46 100644 --- a/src/petasos/petasos.go +++ b/src/petasos/petasos.go @@ -25,12 +25,15 @@ import ( "github.com/Comcast/webpa-common/concurrent" "github.com/Comcast/webpa-common/device" "github.com/Comcast/webpa-common/logging" + "github.com/Comcast/webpa-common/logging/logginghttp" "github.com/Comcast/webpa-common/server" "github.com/Comcast/webpa-common/service" "github.com/Comcast/webpa-common/service/monitor" "github.com/Comcast/webpa-common/service/servicecfg" "github.com/Comcast/webpa-common/service/servicehttp" + "github.com/Comcast/webpa-common/xhttp/xcontext" "github.com/go-kit/kit/log/level" + "github.com/justinas/alice" "github.com/spf13/pflag" "github.com/spf13/viper" ) @@ -87,7 +90,10 @@ func petasos(arguments []string) int { RedirectCode: http.StatusTemporaryRedirect, } - _, petasosServer, done = webPA.Prepare(logger, nil, metricsRegistry, redirectHandler) + requestFunc = logginghttp.SetLogger(redirectHandler.Logger, logginghttp.Header("X-Webpa-Device-Name", "device_id"), logginghttp.Header("Authorization", "authorization")) + decoratedHandler = alice.New(xcontext.Populate(0, requestFunc)).Then(redirectHandler) + + _, petasosServer, done = webPA.Prepare(logger, nil, metricsRegistry, decoratedHandler) signals = make(chan os.Signal, 1) )