Skip to content

Commit

Permalink
feat(renderer): Handling text/plain for error
Browse files Browse the repository at this point in the history
Signed-off-by: Vincent Boutour <bob@vibioh.fr>
ViBiOh committed Aug 5, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 2523035 commit dd89e6a
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions pkg/renderer/handlers.go
Original file line number Diff line number Diff line change
@@ -47,6 +47,12 @@ func (s *Service) Redirect(w http.ResponseWriter, r *http.Request, pathname stri
}

func (s *Service) Error(w http.ResponseWriter, r *http.Request, content map[string]any, err error, opts ...ErrorOption) {
ctx := r.Context()

if r.Header.Get("Accept") == "text/plain" && httperror.HandleError(ctx, w, err) {
return
}

content = s.feedContent(content)

var config errOption
@@ -60,8 +66,6 @@ func (s *Service) Error(w http.ResponseWriter, r *http.Request, content map[stri
content[message.Key] = message
}

ctx := r.Context()

if !config.noLog {
httperror.Log(ctx, err, status, statusMessage)
}

0 comments on commit dd89e6a

Please sign in to comment.