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

Context handler. More...

+ Inheritance diagram for TdjContextHandler:

Public Member Functions

 TdjContextHandler (const string ContextPath)
 Create a ContextHandler.
 
 ~TdjContextHandler ()
 Destructor.
 
IContext GetCurrentContext ()
 The internal IContext field.
 
 SetInitParameter (const string Key, const string Value)
 Set initialization parameter. More...
 
 DoStart ()
 Start the handler.
 
 DoStop ()
 Stop the handler.
 
 Handle (const string Target, TdjServerContext Context, TdjRequest Request, TdjResponse Response)
 Handle a HTTP request. More...
 
- Public Member Functions inherited from TdjHandlerWrapper
 AddHandler (const IHandler Handler)
 Add a handler to the container. More...
 
 RemoveHandler (const IHandler Handler)
 Remove a handler from the container. More...
 
 DoStart ()
 Start the handler.
 
 DoStop ()
 Stop the handler.
 
 Handle (const string Target, TdjServerContext Context, TdjRequest Request, TdjResponse Response)
 Handle a HTTP request. More...
 
- 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

TStrings ConnectorNames
 
string ContextPath
 
IHandler ErrorHandler
 
- Public Attributes inherited from TdjHandlerWrapper
IHandler Handler
 
- 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

Boolean ContextMatches (const string ConnectorName, const string Target)
 Check if the Document matches this context. More...
 
string ToConnectorName (TdjServerContext Context)
 Creates connector name in the form 'host:port'. More...
 
- Protected Member Functions inherited from TdjHandlerWrapper
TIdHTTPSession GetSession (TdjServerContext Context, TdjRequest Request, TdjResponse Response, const Boolean Create)
 Get a HTTP session.
 
- Protected Member Functions inherited from TdjAbstractHandlerContainer
 AddHandler (const IHandler Handler)
 Add a handler. More...
 
 RemoveHandler (const IHandler Handler)
 Remove a handler. 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

Context handler.

Member Function Documentation

◆ ContextMatches()

Boolean TdjContextHandler::ContextMatches ( const string  ConnectorName,
const string  Target 
)
protected

Check if the Document matches this context.

Parameters
ConnectorNamethe connector name (like 'host:port'
Targetthe target URL document
Returns
True if the context matches the connector name and target URL document

References ConnectorNames, and ContextPath.

Referenced by TdjWebComponentContextHandler::Handle().

◆ Handle()

TdjContextHandler::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

◆ SetInitParameter()

TdjContextHandler::SetInitParameter ( const string  Key,
const string  Value 
)

Set initialization parameter.

Parameters
Keyinit parameter name
Valueinit parameter value

References TdjAbstractConfig::Add(), and TdjLifeCycle::CheckStarted().

◆ ToConnectorName()

string TdjContextHandler::ToConnectorName ( TdjServerContext  Context)
protected

Creates connector name in the form 'host:port'.

Returns
connector name

Referenced by TdjWebComponentContextHandler::Handle().

Member Data Documentation

◆ ConnectorNames

TStrings TdjContextHandler::ConnectorNames
See also
FConnectorNames For reading

Referenced by ContextMatches().

◆ ContextPath

◆ ErrorHandler

IHandler TdjContextHandler::ErrorHandler
See also
FErrorHandler For reading
SetErrorHandler For writing