Return Types in Application.cfc

Peter sent in an interesting question this morning, especially as it relates to my last presentation:

Just wanted to quickly check something about your App.cfc reference: The onApplicationStart and onRequestStart functions have a returntype of Boolean, whilst the rest are all Void. Is there a reason for these two being different than the others, particularly the onSessionStart function?

The fact that you can return true or false in onApplicationStart and onRequestStart simply are ways to let you abort the application start up, or request, based on some condition. The example I believe I gave in my presentation was doing a quick database check. If the check fails, then send some kind of message to the admin and prevent the application from starting up. You could do the same in onRequestStart, although it is probably overkill to check every request. What you could do instead is log the last time you checked (in the application scope for example), and check only if sixty minutes have passed.

Anyone out there using something like this in their Application.cfc files?

Raymond Camden's Picture

About Raymond Camden

Raymond is a developer advocate. He focuses on JavaScript, serverless and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support. You can even buy me a coffee!

Lafayette, LA https://www.raymondcamden.com

Comments