GoogleCloudPlatform / functions-framework

The Contract for Building New Function Frameworks
Apache License 2.0
120 stars 12 forks source link

Lifecyle Hooks #56

Open grant opened 2 years ago

grant commented 2 years ago

Certain use-cases require function invocations on certain events related to a container's lifecycle or individual function invocation lifecycle.

Here are some possible examples:

An example API could be the following:

functionsframework.on('bad_request', (e, req, res, next) {
    if (e.message === "Bad request") {
        res.status(400).json({error: {msg: e.message, stack: e.stack}});
    }
});

Feel free to add to this issue for your use-case in a comment.