I have probably asked this before, but don't remember the answer anymore. What I'm asking here is that could we have a request served hook / shutdown functions in OpenResty? What I'm asking is to have this kind of thing in OpenResty:
http://php.net/manual/en/function.register-shutdown-function.php
E.g. a method to register shutdown / cleanup functions that you can use to, for example:
- release acquired resources (close database connectons / release them to connection pool)
- release locks
These registered functions should be called when user calls these:
- ngx.exit
- ngx.redirect
- ngx.exec
and
- in case of error(?)
I do have a few user cases for these in my OpenResty projects.
This would also be interesting to have:
http://php.net/manual/en/function.set-error-handler.php