Skip to content
This repository has been archived by the owner on Jun 26, 2023. It is now read-only.

Commit

Permalink
readable http error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
aaperis committed Apr 21, 2023
1 parent fbc0e59 commit a50700b
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,24 +78,23 @@ func (p *Proxy) ServeHTTP(w http.ResponseWriter, r *http.Request) {
}

func (p *Proxy) internalServerError(w http.ResponseWriter, r *http.Request) {
log.Debug("internal server error")
log.Debugf("Internal server error for request (%v)", r)
w.WriteHeader(500)
w.WriteHeader(http.StatusInternalServerError)
}

func (p *Proxy) notAllowedResponse(w http.ResponseWriter, _ *http.Request) {
log.Debug("not allowed response")
w.WriteHeader(403)
w.WriteHeader(http.StatusForbidden)
}

func (p *Proxy) notAcceptableResponse(w http.ResponseWriter, _ *http.Request) {
log.Debug("not acceptable response")
w.WriteHeader(406)
w.WriteHeader(http.StatusNotAcceptable)
}

func (p *Proxy) notAuthorized(w http.ResponseWriter, _ *http.Request) {
log.Debug("not authorized")
w.WriteHeader(401) // Actually correct!
w.WriteHeader(http.StatusUnauthorized)
}

func (p *Proxy) allowedResponse(w http.ResponseWriter, r *http.Request) {
Expand Down

0 comments on commit a50700b

Please sign in to comment.