Skip to content
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

Lifecyle Hooks #56

Open
grant opened this issue Apr 15, 2022 · 0 comments
Open

Lifecyle Hooks #56

grant opened this issue Apr 15, 2022 · 0 comments

Comments

@grant
Copy link
Contributor

grant commented Apr 15, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants