-
Notifications
You must be signed in to change notification settings - Fork 228
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix the values passed to the callback function for fail(). This fixes #257 #258
Conversation
…penfaas#257 Signed-off-by: Hans Rakers <hans@shoq.com>
When do you think you can do this review and test @viveksyngh? |
@@ -85,9 +85,9 @@ class FunctionContext { | |||
} | |||
|
|||
fail(value) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Think of this example, it will return a HTTP 200, and I don't think that's what you wanted.
return context
.fail(result)
The code should probably stay the same as it is, but then change the middleware closure, with something like this:
return res.status(fnContext.status() || 500)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you share a handler example that we can use for an end to end test?
return context
.fail("Not OK")
Should give 500 and "Not OK"
return context
.succeed("OK")
Gives 200 and "OK"
return context.status(401)
.fail("Not authorized")
Gives 401 - Not authorized
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See notes please
@hrak please can you see the notes I posted last week? |
Hi! Sorry, life happened in the meantime, in the process of buying a house. Will address this asap. |
Not a problem. We appreciate the contribution and it will make things better. |
I'm going to fix this since we've waited long enough to have it resolved and I have a few minutes to test my work at the same time. Thanks again for your interest @hrak If you value our work and project, consider becoming a GitHub Sponsor if you are not already. |
Fix the values passed to the callback function for fail(). This fixes #257
Description
This PR makes the fail() function work the same way as success(), allowing custom status codes and return content.
Motivation and Context
See #257 for details
Which issue(s) this PR fixes
Fixes #257
How Has This Been Tested?
verify.sh
Types of changes
Impact to existing users
Existing users that rely on the current behavior of
fail()
always returning500 Internal Server Error
will have to alter their code.Checklist:
git commit -s