-
Notifications
You must be signed in to change notification settings - Fork 15
Open
Description
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:
on('bad_request', (req, res) => {})- Handle bad HTTP request (400)
on('startup', (req, res) => {})- Invoke once after the container is started and before the first HTTP request.
on('shutdown', (req, res) => {})- Invoke once before the container is terminated.
on('before_function', (req, res) => {})- Invoke before every function invocation
on('after_function', (req, res) => {})- Invoke after every function invocation
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.
Reactions are currently unavailable