coldbox.system

Class RestHandler

lucee.Component
    extended by coldbox.system.FrameworkSupertype
      extended by coldbox.system.EventHandler
        extended by coldbox.system.RestHandler

Copyright Since 2005 ColdBox Framework by Luis Majano and Ortus Solutions, Corp www.ortussolutions.com --- Base class for all RESTFul event handlers

Class Attributes:
  • synchronized : false
  •  
  • accessors : false
  •  
  • persistent : false
  •  
  • author : Luis Majano
  •  
    Method Summary
    any aroundHandler([any event], [any rc], [any prc], [any targetAction], [any eventArguments])
         Our Rest handler adds a nice around handler that will be active for all handlers.
    any onAnyOtherException([any event], [any rc], [any prc], [any eventArguments], [any exception='[runtime expression]'])
         Action for 'any' exceptions, ie when not caught by previous catch statements.
    any onAuthenticationFailure([any event='[runtime expression]'], [any rc='[runtime expression]'], [any prc='[runtime expression]'], [any abort='false'], [any exception='[runtime expression]'])
         Action that can be used for authentication failures.
    any onAuthorizationFailure([any event='[runtime expression]'], [any rc='[runtime expression]'], [any prc='[runtime expression]'], [any abort='false'], [any exception='[runtime expression]'])
         Action that can be used for authorization failures.
    any onEntityNotFoundException([any event], [any rc], [any prc], [any eventArguments], [any exception='[runtime expression]'])
         Action that can be used when an entity or record is not found.
    any onError([any event], [any rc], [any prc], [any faultAction=''], [any exception='[runtime expression]'], [any eventArguments='[runtime expression]'])
         Implicit action that detects exceptions on your handlers and processes them.
    any onExpectationFailed([any event='[runtime expression]'], [any rc='[runtime expression]'], [any prc='[runtime expression]'], [any message='An expectation for the request failed. Could not proceed'])
         Utility method for when an expectation of the request fails ( e.
    any onInvalidHTTPMethod([any event], [any rc], [any prc], [any faultAction], [any eventArguments])
         Action used when the framework detects and Invalid HTTP method for the action.
    any onInvalidRoute([any event], [any rc], [any prc])
         Action for when a route is invalid or not found.
    any onMissingAction([any event], [any rc], [any prc], [any missingAction], [any eventArguments])
         Action used when the original action does not exist in a handler.
    any onValidationException([any event], [any rc], [any prc], [any eventArguments], [any exception='[runtime expression]'])
         Action that can be used when validation exceptions ocur.
     
    Methods inherited from class coldbox.system.EventHandler
    _actionExists, _actionMetadata, _privateInvoker, init, onHandlerDIComplete
     
    Methods inherited from class coldbox.system.FrameworkSupertype
    announce, announceInterception, async, back, externalView, forAttribute, getCache, getCachebox, getColdBoxSetting, getController, getDateTimeHelper, getEnv, getFlash, getFlow, getInstance, getIsoTime, getJsonUtil, getLog, getLogBox, getModuleConfig, getModuleSettings, getRenderer, getRequestCollection, getRequestContext, getRootWireBox, getSetting, getSystemProperty, getSystemSetting, getUserSessionIdentifier, getWirebox, ifNull, ifPresent, inDebugMode, includeUDF, isDevelopment, isProduction, isTesting, layout, listen, loadApplicationHelpers, locateDirectoryPath, locateFilePath, persistVariables, populate, populateModel, relocate, renderExternalView, renderLayout, renderview, runEvent, runRoute, setCachebox, setController, setEnv, setFlash, setFlow, setJsonUtil, setLog, setLogBox, setSetting, setWirebox, settingExists, throwIf, throwUnless, toJson, unless, view, when
     
    Methods inherited from class lucee.Component
    None

    Method Detail

    aroundHandler

    public any aroundHandler([any event], [any rc], [any prc], [any targetAction], [any eventArguments])

    Our Rest handler adds a nice around handler that will be active for all handlers that leverage it. So it can add uniformity, exception handling, tracking and more.

    Parameters:
    event - The request context
    rc - The rc reference
    prc - The prc reference
    targetAction - The action UDF to execute
    eventArguments - The original event arguments

    onAnyOtherException

    public any onAnyOtherException([any event], [any rc], [any prc], [any eventArguments], [any exception='[runtime expression]'])

    Action for 'any' exceptions, ie when not caught by previous catch statements

    Parameters:
    event - The request context
    rc - The rc reference
    prc - The prc reference
    eventArguments - The original event arguments
    exception - The thrown exception

    onAuthenticationFailure

    public any onAuthenticationFailure([any event='[runtime expression]'], [any rc='[runtime expression]'], [any prc='[runtime expression]'], [any abort='false'], [any exception='[runtime expression]'])

    Action that can be used for authentication failures. You can point to this action from cbsecurity, cbauth, etc or call it a-la-carte. It also monitors cbsecurity convention of validator results for setting error messages into the data packet

    Parameters:
    event - The request context
    rc - The rc reference
    prc - The prc reference
    abort - Hard abort the request if passed, defaults to false
    exception - The thrown exception
    Returns:
    401

    onAuthorizationFailure

    public any onAuthorizationFailure([any event='[runtime expression]'], [any rc='[runtime expression]'], [any prc='[runtime expression]'], [any abort='false'], [any exception='[runtime expression]'])

    Action that can be used for authorization failures. You can point to this action from cbsecurity, cbauth, etc or call it a-la-carte. It will check for cbsecurity validation results and set the appropriate error messages

    Parameters:
    event - The request context
    rc - The rc reference
    prc - The prc reference
    abort - Hard abort the request if passed, defaults to false
    exception - The thrown exception

    onEntityNotFoundException

    public any onEntityNotFoundException([any event], [any rc], [any prc], [any eventArguments], [any exception='[runtime expression]'])

    Action that can be used when an entity or record is not found. Can be called manually or automatically via thrown exceptions in the around handler

    Parameters:
    event - The request context
    rc - The rc reference
    prc - The prc reference
    eventArguments - The original event arguments
    exception - The thrown exception

    onError

    public any onError([any event], [any rc], [any prc], [any faultAction=''], [any exception='[runtime expression]'], [any eventArguments='[runtime expression]'])

    Implicit action that detects exceptions on your handlers and processes them

    Parameters:
    event - The request context
    rc - The rc reference
    prc - The prc reference
    faultAction - The action that blew up
    exception - The thrown exception
    eventArguments - The original event arguments

    onExpectationFailed

    public any onExpectationFailed([any event='[runtime expression]'], [any rc='[runtime expression]'], [any prc='[runtime expression]'], [any message='An expectation for the request failed. Could not proceed'])

    Utility method for when an expectation of the request fails ( e.g. an expected parameter is not provided ) - It will output a 417 status code (event.STATUS.EXPECTATION_FAILED) - Add the error flag - Add an failure message to the data packet which you can customize

    Parameters:
    event - The request context
    rc - The rc reference
    prc - The prc reference
    message - The failure message sent in the request package
    Returns:
    417:Expectation Failed

    onInvalidHTTPMethod

    public any onInvalidHTTPMethod([any event], [any rc], [any prc], [any faultAction], [any eventArguments])

    Action used when the framework detects and Invalid HTTP method for the action

    Parameters:
    event - The request context
    rc - The rc reference
    prc - The prc reference
    faultAction - The action that was secured
    eventArguments - The original event arguments

    onInvalidRoute

    public any onInvalidRoute([any event], [any rc], [any prc])

    Action for when a route is invalid or not found. Usually you use this in your router as a catch all.

    // Catch All Resource
    route( "/:anything" ).to( "MyHandler.onInvalidRoute" );
    

    Parameters:
    event - The request context
    rc - The rc reference
    prc - The prc reference
    Returns:
    404:Not Found

    onMissingAction

    public any onMissingAction([any event], [any rc], [any prc], [any missingAction], [any eventArguments])

    Action used when the original action does not exist in a handler.

    Parameters:
    event - The request context
    rc - The rc reference
    prc - The prc reference
    missingAction - The missing action
    eventArguments - The original event arguments

    onValidationException

    public any onValidationException([any event], [any rc], [any prc], [any eventArguments], [any exception='[runtime expression]'])

    Action that can be used when validation exceptions ocur. Can be called manually or automatically via thrown exceptions in the around handler

    Parameters:
    event - The request context
    rc - The rc reference
    prc - The prc reference
    eventArguments - The original event arguments
    exception - The thrown exception