This commit is contained in:
Joren Schipman 2024-05-04 01:39:28 +02:00
parent 67156fee7e
commit ef554197e6
Signed by untrusted user who does not match committer: Joren
GPG Key ID: 280E33DFBC0F1B55

View File

@ -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) {