From af71f8f9b058c3d9daf7376a9f9e055c42a0d01a Mon Sep 17 00:00:00 2001 From: Ahmet Alp Balkan Date: Tue, 10 Jul 2018 21:49:06 -0700 Subject: [PATCH] frontend: refactor http.Handler decoration Signed-off-by: Ahmet Alp Balkan --- src/frontend/main.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/frontend/main.go b/src/frontend/main.go index 863c469..0a486ff 100644 --- a/src/frontend/main.go +++ b/src/frontend/main.go @@ -95,15 +95,15 @@ func main() { r.HandleFunc("/cart/checkout", svc.placeOrderHandler).Methods(http.MethodPost) r.PathPrefix("/static/").Handler(http.StripPrefix("/static/", http.FileServer(http.Dir("./static/")))) + var handler http.Handler = r + handler = &logHandler{log: log, next: handler} // add logging + handler = ensureSessionID(handler) // add session ID + handler = &ochttp.Handler{ // add opencensus instrumentation + Handler: handler, + Propagation: &b3.HTTPFormat{}} + log.Infof("starting server on " + addr + ":" + srvPort) - loggedHandler := &logHandler{log: log, next: r} - log.Fatal(http.ListenAndServe( - addr+":"+srvPort, - &ochttp.Handler{ - Handler: http.HandlerFunc(ensureSessionID(loggedHandler)), - Propagation: &b3.HTTPFormat{}, - }, - )) + log.Fatal(http.ListenAndServe(addr+":"+srvPort, handler)) } func mustMapEnv(target *string, envKey string) {