frontend: refactor http.Handler decoration
Signed-off-by: Ahmet Alp Balkan <ahmetb@google.com>
This commit is contained in:
parent
61cf05844d
commit
af71f8f9b0
1 changed files with 8 additions and 8 deletions
|
@ -95,15 +95,15 @@ func main() {
|
||||||
r.HandleFunc("/cart/checkout", svc.placeOrderHandler).Methods(http.MethodPost)
|
r.HandleFunc("/cart/checkout", svc.placeOrderHandler).Methods(http.MethodPost)
|
||||||
r.PathPrefix("/static/").Handler(http.StripPrefix("/static/", http.FileServer(http.Dir("./static/"))))
|
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)
|
log.Infof("starting server on " + addr + ":" + srvPort)
|
||||||
loggedHandler := &logHandler{log: log, next: r}
|
log.Fatal(http.ListenAndServe(addr+":"+srvPort, handler))
|
||||||
log.Fatal(http.ListenAndServe(
|
|
||||||
addr+":"+srvPort,
|
|
||||||
&ochttp.Handler{
|
|
||||||
Handler: http.HandlerFunc(ensureSessionID(loggedHandler)),
|
|
||||||
Propagation: &b3.HTTPFormat{},
|
|
||||||
},
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func mustMapEnv(target *string, envKey string) {
|
func mustMapEnv(target *string, envKey string) {
|
||||||
|
|
Loading…
Reference in a new issue