Skip to content
Snippets Groups Projects
Verified Commit 9101b7a0 authored by blallo's avatar blallo
Browse files

Improve logging and change error value

parent 666a7356
No related branches found
No related tags found
No related merge requests found
......@@ -19,6 +19,8 @@ var (
func main() {
flag.Parse()
log.Printf("Starting on 127.0.0.1:%d\n", *port)
http.HandleFunc("/", authHandlerFunc)
log.Fatal(http.ListenAndServe(
fmt.Sprintf("127.0.0.1:%d", *port),
......@@ -50,15 +52,17 @@ func authHandlerFunc(w http.ResponseWriter, r *http.Request) {
http.Error(w, "internal server error", http.StatusInternalServerError)
return
}
switch resp.Status {
case auth.StatusOK:
w.WriteHeader(http.StatusOK)
return
case auth.StatusInsufficientCredentials:
http.Error(w, "wrong credentials", http.StatusForbidden)
http.Error(w, "not allowed", http.StatusForbidden)
return
case auth.StatusError:
http.Error(w, "internal server error", http.StatusInternalServerError)
log.Printf("status (user: %s): %s", p.User, resp.Status)
http.Error(w, "unauthorized", http.StatusUnauthorized)
return
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment