THandlers

THandlers

THandlers This class is responsible for keeping a list of registered handlers for the IntraWeb application. A content handler is similar to TURLMappers in previous IntraWeb versions. The application developer creates an instance of a TContentBase descendant and registers it using the THandlers class. When a request is received, the IntraWeb server searches for a match in the list. If a match is found, the request is then passed to the TContentBase descendand. There are a few demos in our CodePlex repository showing the basic usage of THandlers and TContentBase classes. All THandlers methods are class methods, meaning that you don’t need to create an instance of THandlers class. UnitIW.Content.HandlersClass hierarchyTObject -> THandlersMethods

Add [Public]

Declaration: class function Add(const aPath, aDocument: string; aHandler: TContentBase): TContentBase; overload;

Description: Adds an instance of TContentBase (or descendant class) to the content handlers list.

Parameters:

  • aPath (string): Path of the document, e.g: ‘/reports/’
  • aDocument (string): Name of the document, e.g: ‘Report1.html’
  • aHandler (TContentBase): The instance that will handle the request

Result: Returns the instance (the same reference received in aHandler parameter).

Example:

THandlers.Add(‘/reports/’, Report1.html, TContentForm.Create(TIWForm1));

means: all requests whose URL ends with ‘/reports/Report1.html’ will be redirected to a TContentForm instance, which uses the TIWForm1 class.


Add [Public]

Declaration: class function Add(const aDocument: string; aHandler: TContentBase): TContentBase; overload;

Description: Adds an instance of TContentBase (or descendant class) to the content handlers list.

Parameters:

  • aDocument (string): Name of the document, e.g: ‘Report1.html’
  • aHandler (TContentBase): The instance that will handle the request

Result: Returns the instance (the same reference received in aHandler parameter).


AddStartHandler [Public]

Declaration: class function AddStartHandler(const aPath, aDocument: string; aHandler: TContentBase): TContentBase;

Description: This function adds an instance of TContentBase (or descendant class) to the content handlers list and also register this instance as the start handler, meaning that this instance will handle all requests starting a new session.

Parameters:

  • aPath (string): Path of the document, e.g: ‘/reports/’
  • aDocument (string): Name of the document, e.g: ‘Report1.html’
  • aHandler (TContentBase): The instance that will handle the request

Result: Returns the instance (the same reference received in aHandler parameter).


AddForExtension [Public]

Declaration: class function AddForExtension(const aExt: string; aHandler: TContentBase): TContentBase;

Description: This method registers an instance of TContentBase (or descendant class) to the content handlers list to handle all requests which URL ends with the specified extension.

Parameters:

  • aExt (string): The file extension, e.g: ‘*.pas’. In this example,all requests whose URL ends with ".pas" extension will be redirected to this handler.
  • aHandler (TContentBase): The instance that will handle the request

Result: Returns the instance (the same reference received in aHandler parameter).


FindMatch [Public]

Declaration: class function FindMatch(aFullPath: string): TContentBase;

Description: Given a path (URL) it finds the TContentBase registered to that path.

Parameters:

  • aFullPath (string): Path or URL of the request

Result: the registered TContentBase instance, or nil if not matches the path.


GetStartHandler [Public]

Declaration: class function GetStartHandler: TContentBase;

Description: Returns the TContentBase instance registered to handle the session start request

Result: A TContentBase instance, or nil if no start handler was registered.