Add logs
This commit is contained in:
parent
67156fee7e
commit
ef554197e6
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user