aboutsummaryrefslogtreecommitdiff
path: root/cmd/cashierd
diff options
context:
space:
mode:
authorNiall Sheridan <nsheridan@gmail.com>2016-06-28 22:38:48 +0100
committerNiall Sheridan <nsheridan@gmail.com>2016-06-28 22:38:48 +0100
commitafd6fa3f8fbaaefae1633404484bd66137f275ad (patch)
tree9c501041fcabe44bfdad536d8e1b782674af0699 /cmd/cashierd
parent814c146f7d0e6fc2ad1add8fa067760b3494acce (diff)
http logging
Diffstat (limited to 'cmd/cashierd')
-rw-r--r--cmd/cashierd/main.go17
1 files changed, 9 insertions, 8 deletions
diff --git a/cmd/cashierd/main.go b/cmd/cashierd/main.go
index 90d7eb9..b91f005 100644
--- a/cmd/cashierd/main.go
+++ b/cmd/cashierd/main.go
@@ -17,6 +17,7 @@ import (
"golang.org/x/oauth2"
+ "github.com/gorilla/handlers"
"github.com/gorilla/mux"
"github.com/gorilla/sessions"
"github.com/nsheridan/cashier/lib"
@@ -183,7 +184,6 @@ type appHandler struct {
func (ah appHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
status, err := ah.h(ah.appContext, w, r)
if err != nil {
- log.Printf("HTTP %d: %q", status, err)
switch status {
case http.StatusNotFound:
http.NotFound(w, r)
@@ -251,16 +251,17 @@ func main() {
HttpOnly: true,
}
- m := mux.NewRouter()
- m.Handle("/", appHandler{ctx, rootHandler})
- m.Handle("/auth/login", appHandler{ctx, loginHandler})
- m.Handle("/auth/callback", appHandler{ctx, callbackHandler})
- m.Handle("/sign", appHandler{ctx, signHandler})
+ r := mux.NewRouter()
+ r.Handle("/", appHandler{ctx, rootHandler})
+ r.Handle("/auth/login", appHandler{ctx, loginHandler})
+ r.Handle("/auth/callback", appHandler{ctx, callbackHandler})
+ r.Handle("/sign", appHandler{ctx, signHandler})
+ h := handlers.LoggingHandler(os.Stdout, r)
fmt.Println("Starting server...")
l := fmt.Sprintf(":%d", config.Server.Port)
if config.Server.UseTLS {
- log.Fatal(http.ListenAndServeTLS(l, config.Server.TLSCert, config.Server.TLSKey, m))
+ log.Fatal(http.ListenAndServeTLS(l, config.Server.TLSCert, config.Server.TLSKey, h))
}
- log.Fatal(http.ListenAndServe(l, m))
+ log.Fatal(http.ListenAndServe(l, h))
}