Add logs
This commit is contained in:
parent
67156fee7e
commit
ef554197e6
@ -1,6 +1,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"html/template"
|
"html/template"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
@ -20,12 +21,20 @@ type PageData struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
http.HandleFunc("/", loginHandler)
|
http.HandleFunc("/", logMiddleware(loginHandler))
|
||||||
http.HandleFunc("/loot", lootHandler)
|
http.HandleFunc("/loot", logMiddleware(lootHandler))
|
||||||
http.HandleFunc("/logout", logoutHandler)
|
http.HandleFunc("/logout", logMiddleware(logoutHandler))
|
||||||
http.HandleFunc("/files/", fileHandler)
|
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) {
|
func loginHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
|
Loading…
Reference in New Issue
Block a user