admin: introducing new page
This commit is contained in:
parent
08fb2ad37c
commit
185262b2e7
3 changed files with 49 additions and 0 deletions
9
main.go
9
main.go
|
|
@ -91,6 +91,15 @@ func main() {
|
|||
GetNextImage,
|
||||
)))
|
||||
|
||||
mux.HandleFunc("/admin/", func(w http.ResponseWriter, r *http.Request) {
|
||||
if authFunc(r) == nil {
|
||||
w.Header().Set("WWW-Authenticate", "Basic realm=\"YouP0m Admin\"")
|
||||
http.Error(w, "You are not allowed to perform this request.", http.StatusUnauthorized)
|
||||
} else {
|
||||
http.ServeFile(w, r, filepath.Join(staticDir, "admin.html"))
|
||||
}
|
||||
})
|
||||
|
||||
log.Println("Ready, listening on", *bind)
|
||||
if err := http.ListenAndServe(*bind, mux); err != nil {
|
||||
log.Fatal("Unable to listen and serve: ", err)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue