Skip to content

Commit

Permalink
Merge pull request #24 from hckrnews/feature/more-than-json
Browse files Browse the repository at this point in the history
Remove accept header
  • Loading branch information
w3nl authored Sep 2, 2022
2 parents b4abe09 + 258e687 commit d146011
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hckrnews/express-callback",
"version": "4.0.3",
"version": "4.0.4",
"description": "Express callback",
"files": [
"src/error-status.js",
Expand Down
7 changes: 6 additions & 1 deletion src/__tests__/express-callback.unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ describe('Test the express callback', () => {
const currentRes = { ...res, values: { ...res.values } };

const controller = () => ({
headers: {},
headers: {
'Content-Type': 'text/csv',
},
statusCode: 200,
body: {},
attachment: true,
Expand Down Expand Up @@ -126,6 +128,9 @@ describe('Test the express callback', () => {
const controller = () => ({
statusCode: 200,
body: {},
headers: {
'Content-Type': 'text/xml',
},
});

const expressCallback = makeExpressCallback({
Expand Down
6 changes: 3 additions & 3 deletions src/express-callback.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ export default function makeExpressCallback({
meta,
});

// also check if we can auto use the accept header
// context.request.headers.accept
const contentType =
response?.headers?.['Content-Type'] ??
context?.request?.headers?.accept ??
'application/json';
response?.headers?.['Content-Type'] ?? 'application/json';

const httpResponse = buildResponse(
response,
Expand Down

0 comments on commit d146011

Please sign in to comment.