Set a proper status code before sending an error status page
This commit is contained in:
		@@ -996,7 +996,7 @@ func (s *Server) writeAccessToken(w http.ResponseWriter, idToken, accessToken, r
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *Server) renderError(w http.ResponseWriter, status int, description string) {
 | 
			
		||||
	if err := s.templates.err(w, http.StatusText(status), description); err != nil {
 | 
			
		||||
	if err := s.templates.err(w, status, description); err != nil {
 | 
			
		||||
		s.logger.Errorf("Server template error: %v", err)
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -226,12 +226,16 @@ func (t *templates) oob(w http.ResponseWriter, code string) error {
 | 
			
		||||
	return renderTemplate(w, t.oobTmpl, data)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (t *templates) err(w http.ResponseWriter, errType string, errMsg string) error {
 | 
			
		||||
func (t *templates) err(w http.ResponseWriter, errCode int, errMsg string) error {
 | 
			
		||||
	w.WriteHeader(errCode)
 | 
			
		||||
	data := struct {
 | 
			
		||||
		ErrType string
 | 
			
		||||
		ErrMsg  string
 | 
			
		||||
	}{errType, errMsg}
 | 
			
		||||
	return renderTemplate(w, t.errorTmpl, data)
 | 
			
		||||
	}{http.StatusText(errCode), errMsg}
 | 
			
		||||
	if err := t.errorTmpl.Execute(w, data); err != nil {
 | 
			
		||||
		return fmt.Errorf("Error rendering template %s: %s", t.errorTmpl.Name(), err)
 | 
			
		||||
	}
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// small io.Writer utility to determine if executing the template wrote to the underlying response writer.
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user