Skip to content

Commit

Permalink
Fallback to json if client wants for statusEnd
Browse files Browse the repository at this point in the history
  • Loading branch information
porsager committed May 6, 2024
1 parent e1d9e17 commit a1f6149
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,16 @@ export default class Request {
}

statusEnd(status, headers) {
return this.end(STATUS_CODES[status], status, headers)
if (this.headers.accept === 'application/json' && !this.type)
this.type = 'application/json'

return this.end(
this.type === 'application/json'
? JSON.stringify(STATUS_CODES[status])
: STATUS_CODES[status],
status,
headers
)
}

status(x) {
Expand Down

0 comments on commit a1f6149

Please sign in to comment.