Last active
January 25, 2017 04:56
-
-
Save sungjunyoung/3bf676d42f0f85695612921407bb455e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var errorResponse = function (statusCode, errorCode, detailMessage) { | |
var messageMap = { | |
400: 'Bad Request', | |
401: 'Unauthonized', | |
403: 'Forbidden', | |
404: 'Not Found', | |
405: 'Method Not Allowd', | |
406: 'Not Acceptable', | |
409: 'Conflict', | |
500: 'Internal Server Error' | |
}; | |
return { | |
statusCode: statusCode, | |
body: JSON.stringify({ | |
code: errorCode, | |
message: messageMap[statusCode], | |
detail: detailMessage | |
}), | |
headers: { | |
'Content-Type': 'application/json', | |
'X-Requested-With' : 'XMLHttpRequest', | |
'Access-Control-Allow-Origin' : '*' | |
} | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is part of my lambda function code, Which allow return HTTP status code with message / enable CORS.
Of course you must check 'lambda proxy integration' in API-Gateway.