diff --git a/loothandler.go b/loothandler.go index 7607dd2..ccafe24 100644 --- a/loothandler.go +++ b/loothandler.go @@ -1,6 +1,7 @@ package main import ( + "fmt" "html/template" "io/ioutil" "log" @@ -20,12 +21,20 @@ type PageData struct { } func main() { - http.HandleFunc("/", loginHandler) - http.HandleFunc("/loot", lootHandler) - http.HandleFunc("/logout", logoutHandler) - http.HandleFunc("/files/", fileHandler) + http.HandleFunc("/", logMiddleware(loginHandler)) + http.HandleFunc("/loot", logMiddleware(lootHandler)) + http.HandleFunc("/logout", logMiddleware(logoutHandler)) + http.HandleFunc("/files/", logMiddleware(fileHandler)) - log.Fatal(http.ListenAndServe(":8080", nil)) + log.Fatal(http.ListenAndServe(":5647", nil)) + fmt.Println("Server started") +} + +func logMiddleware(next http.HandlerFunc) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + log.Printf("[%s] %s %s\n", r.Method, r.RemoteAddr, r.URL.Path) + next(w, r) + } } func loginHandler(w http.ResponseWriter, r *http.Request) {