diff options
Diffstat (limited to '')
-rw-r--r-- | main.go | 11 |
1 files changed, 10 insertions, 1 deletions
@@ -47,6 +47,7 @@ func main() { mux := http.NewServeMux() + // handlers that DO NOT require authentification mux.Handle("GET /login", loginPage()) mux.HandleFunc("POST /login", handleLogin) mux.Handle("GET /logout", handleLogout()) @@ -57,11 +58,13 @@ func main() { handler = handlers.CombinedLoggingHandler(os.Stderr, handler) handler = handlers.ProxyHeaders(handler) - // the real content, needing authentification + // setup authentification authMux := http.NewServeMux() mux.Handle("/", RequireAuth(authMux)) + // handlers that required authentification authMux.Handle("GET /{$}", indexPage()) + authMux.Handle("GET /", notfound()) log.Fatal(http.ListenAndServe(os.Getenv("GOSTEN_ADDRESS"), handler)) } @@ -79,3 +82,9 @@ func indexPage() http.HandlerFunc { showTemplate(w, "index", u.Name) } } + +func notfound() http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + showTemplate(w, "404", r.RequestURI) + } +} |