Skip to content

Commit

Permalink
feat: support WebAPI headers in response
Browse files Browse the repository at this point in the history
  • Loading branch information
davidbonnet committed Sep 3, 2020
1 parent 797d13c commit 8fc0cb2
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/respond.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,14 @@ export function respond(response, options) {
response.statusCode = statusCode
}
if (headers != null) {
// TODO: Check if headers are iterable
for (const name in headers) {
response.setHeader(name, headers[name])
if (typeof headers.entries === 'function') {
for (const value of headers.entries()) {
response.setHeader(value[0], headers[value[1]])
}
} else {
for (const name in headers) {
response.setHeader(name, headers[name])
}
}
}
if (body != null) {
Expand Down

0 comments on commit 8fc0cb2

Please sign in to comment.