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
Interrupting middlewares running progress #72
Comments
That's definitely a fair point. We should definitely add an example like this in the doc and a test. Plus it might be interesting to create a "keep lambda warm" middleware in the default middleware package |
I investigated this.
instead of I can make a PR with some additions to the docs and middleware code |
Great example @NPCRUS, thanks. The only thing I would be concerned is that when you run this you are going to skip any middleware in any other phase (after/error), so there might be unexpected behaviours. Let's just imagine the case that you have an output serializer and an Plus it would be great to have an example like this documented, tested and maybe with a simplified API (rather than having to resort to the old So, quite open for discussion here, feel free to provide more inputs and ideas. Calling also @DavidWells and @dkatavic for discussing this :) |
@lmammino The point of warming up lambdas is to skip any logic and other things and just make the container running. Other thing here is maybe to provide some sort of check function here as in example:
So, not everyone uses |
Great idea with the In this issue, I will keep focusing more on how we make easy to write middlewares that can stop the execution flow |
I think this is great example of how to abort if a condition is met
I think if Like I could have output middleware logging stuff etc that I only want to run when the logic of the function runs and not on If you One thing I'd add as a "best practice" is a clearer log message to that example: module.exports = (config) => {
return ({
before: (handler, next) => {
if (handler.event.warmup === true) {
console.log('👋 Exiting early via warmUpMiddleware')
return handler.context.succeed()
}
next()
}
})
} How does express/koa handle early middleware bails? |
Another one thing here is that |
@DavidWells Express/koa provide res/req object in any middleware in chain. So in any middleware you can execute |
Hello guys. Is there a way to interrupt middleware in the middle of execution and execute callback to return something as result as in example
Or is there any other way to do it?
Best regards
The text was updated successfully, but these errors were encountered: