Skip to content

Lifecyle Hooks #56

@grant

Description

@grant

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions