Merge "website: make /apiget in demo authenticated too"

This commit is contained in:
Mathieu Lonjaret 2016-01-18 23:41:30 +00:00 committed by Gerrit Code Review
commit 35b201a71e
1 changed files with 7 additions and 4 deletions

View File

@ -137,11 +137,14 @@ func repro(host, userpass string) error {
fmt.Fprint(w, clientCode())
})
mux.HandleFunc("/apiget", func(w http.ResponseWriter, r *http.Request) {
if r.Method != "GET" {
http.Error(w, "NOT A GET", http.StatusBadRequest)
return
if up.isAllowed(r) {
if r.Method != "GET" {
http.Error(w, "NOT A GET", http.StatusBadRequest)
return
}
fmt.Fprintf(w, "Hello World, it is %v, and I received a %v for %v.", time.Now(), r.Method, r.URL.Path)
}
fmt.Fprintf(w, "Hello World, it is %v, and I received a %v for %v.", time.Now(), r.Method, r.URL.Path)
sendUnauthorized(w, r)
})
mux.HandleFunc("/apipost", func(w http.ResponseWriter, r *http.Request) {
if up.isAllowed(r) {