github.com/googlecloudplatform/kubernetes-workshops@v0.0.0-20180501174420-d8199445b2c3/bundles/kubernetes-101/workshop/app/handlers/logging.go (about)

     1  package handlers
     2  
     3  import (
     4  	"fmt"
     5  	"net/http"
     6  	"time"
     7  )
     8  
     9  func LoggingHandler(h http.Handler) http.Handler {
    10  	return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
    11  		format := "%s - - [%s] \"%s %s %s\" %s\n"
    12  		fmt.Printf(format, r.RemoteAddr, time.Now().Format(time.RFC1123),
    13  			r.Method, r.URL.Path, r.Proto, r.UserAgent())
    14  		h.ServeHTTP(w, r)
    15  	})
    16  }