Daraja HTTP Framework  2.0
HTTP server framework for Object Pascal
TdjWebComponentHandler Class Reference

Web Component handler. More...

+ Inheritance diagram for TdjWebComponentHandler:

Public Member Functions

 TdjWebComponentHandler ()
 Create a ContextHandler. More...
 
 ~TdjWebComponentHandler ()
 Destructor.
 
 AddMapping (const TdjWebComponentMapping Mapping)
 Add a mapping.
 
 AddWithMapping (const TdjWebComponentHolder Holder, const string PathSpec)
 Add a Web Component holder with mapping. More...
 
TdjWebComponentHolder CreateHolder (const TdjWebComponentClass WebComponentClass)
 Create a TdjWebComponentHolder for a WebComponentClass. More...
 
TdjWebComponentHolder FindHolder (const TdjWebComponentClass WebComponentClass)
 Find a TdjWebComponentHolder for a WebComponentClass. More...
 
 Handle (const string Target, TdjServerContext Context, TdjRequest Request, TdjResponse Response)
 Handle a HTTP request. More...
 
 DoStart ()
 Start the handler.
 
 DoStop ()
 Stop the handler.
 
- Public Member Functions inherited from TdjAbstractHandler
 TdjAbstractHandler ()
 Constructor.
 
 DoStart ()
 Start the handler.
 
 DoStop ()
 Start the handler.
 
 Handle (const string Target, TdjServerContext Context, TdjRequest Request, TdjResponse Response)
 Handle a HTTP request. More...
 
- Public Member Functions inherited from TdjLifeCycle
 TdjLifeCycle ()
 Constructor.
 
 Start ()
 Start the handler. More...
 
 Stop ()
 Stop the handler. More...
 
Boolean IsStarted ()
 
Boolean IsStopped ()
 

Public Attributes

IContext WebComponentContext
 
TdjWebComponentMappings WebComponentMappings
 
TdjWebComponentHolders WebComponents
 
- Public Attributes inherited from TdjLifeCycle
Boolean Started
 True if the state is "started". More...
 
Boolean Stopped
 True if the state is "stopped". More...
 

Protected Member Functions

TdjWebComponentHolder FindComponent (const string ATarget)
 Find matching component. More...
 
- Protected Member Functions inherited from TdjLifeCycle
 DoStart ()
 Execute the custom start code.
 
 DoStop ()
 Execute the custom stop code.
 
 CheckStarted ()
 Raises an exception if the lifecycle is in "started" state.
 
 CheckStopped ()
 Raises an exception if the lifecycle is in "stopped" state.
 

Detailed Description

Web Component handler.

An instance of this class is created per context.

It holds a list of web components and their path mappings, and passes incoming requests to the matching web component.

Constructor & Destructor Documentation

◆ TdjWebComponentHandler()

TdjWebComponentHandler::TdjWebComponentHandler ( )

Create a ContextHandler.

Use a ContextConfig (required argument) to configure the route mappings.

Member Function Documentation

◆ AddWithMapping()

TdjWebComponentHandler::AddWithMapping ( const TdjWebComponentHolder  Holder,
const string  PathSpec 
)

Add a Web Component holder with mapping.

Parameters
Holdera Web Component holder
PathSpeca path spec

Referenced by TdjWebComponentContextHandler::Add(), and TdjWebComponentContextHandler::AddWebComponent().

◆ CreateHolder()

TdjWebComponentHolder TdjWebComponentHandler::CreateHolder ( const TdjWebComponentClass  WebComponentClass)

Create a TdjWebComponentHolder for a WebComponentClass.

Parameters
WebComponentClassthe Web Component class
Returns
a TdjWebComponentHolder with the WebComponentClass.

◆ FindComponent()

TdjWebComponentHolder TdjWebComponentHandler::FindComponent ( const string  ATarget)
protected

Find matching component.

Parameters
ATargetthe URL document path.

◆ FindHolder()

TdjWebComponentHolder TdjWebComponentHandler::FindHolder ( const TdjWebComponentClass  WebComponentClass)

Find a TdjWebComponentHolder for a WebComponentClass.

Parameters
WebComponentClassthe Web Component class
Returns
a TdjWebComponentHolder with the WebComponentClass or nil if the WebComponentClass is not registered

Referenced by TdjWebComponentContextHandler::Add().

◆ Handle()

TdjWebComponentHandler::Handle ( const string  Target,
TdjServerContext  Context,
TdjRequest  Request,
TdjResponse  Response 
)

Handle a HTTP request.

Parameters
TargetRequest target
ContextHTTP server context
RequestHTTP request
ResponseHTTP response
Exceptions
EWebComponentExceptionif an exception occurs that interferes with the component's normal operation
See also
IHandler

Referenced by TdjWebComponentContextHandler::DoHandle().

Member Data Documentation

◆ WebComponentContext

IContext TdjWebComponentHandler::WebComponentContext
See also
FWebComponentContext For reading

◆ WebComponentMappings

TdjWebComponentMappings TdjWebComponentHandler::WebComponentMappings
See also
FMappings For reading

◆ WebComponents

TdjWebComponentHolders TdjWebComponentHandler::WebComponents
See also
FWebComponentHolders For reading