Daraja HTTP Framework 3.0.7-SNAPSHOT
HTTP server framework for Object Pascal
Loading...
Searching...
No Matches
TdjGenericWebComponent Class Reference

Defines a generic Web Component. More...

Inheritance diagram for TdjGenericWebComponent:
IWebComponent TdjWebComponent TdjWebComponentHolder TdjWebComponentHolders

Public Member Functions

 TdjGenericWebComponent ()
 Constructor.
 ~TdjGenericWebComponent ()
 Destructor.
TIdHTTPSession GetSession (TdjServerContext Context, TdjRequest Request, TdjResponse Response, const Boolean Create=True)
 Get or create a HTTP session.
IWebComponentConfig GetWebComponentConfig ()
 Returns a IWebComponentConfig object, which contains initialization parameters for this component.
 Init ()
 A convenience method which can be overridden so that there is no need to call inherited Init(config).
 Init (const IWebComponentConfig Config)
 Called by the container on startup.
 Service (TdjServerContext Context, TdjRequest Request, TdjResponse Response)
 Handle a HTTP request.

Public Attributes

IWebComponentConfig Config

Detailed Description

Defines a generic Web Component.

Constructor & Destructor Documentation

◆ TdjGenericWebComponent()

TdjGenericWebComponent::TdjGenericWebComponent ( )

Constructor.

References TdjGenericWebComponent(), and Create().

Referenced by TdjGenericWebComponent(), and ~TdjGenericWebComponent().

◆ ~TdjGenericWebComponent()

TdjGenericWebComponent::~TdjGenericWebComponent ( )

Destructor.

References TdjGenericWebComponent(), Config, and Init().

Member Function Documentation

◆ GetSession()

TIdHTTPSession TdjGenericWebComponent::GetSession ( TdjServerContext Context,
TdjRequest Request,
TdjResponse Response,
const Boolean Create = True )

Get or create a HTTP session.

Note
it requires the current TdjServerContext so calling it from one of the HTTP method handlers is not possible. It can be called from the Servive method.
if the context was created with the Auto Session option, this method will always return a session independent of the Create parameter
Parameters
ContextHTTP server context
RequestHTTP request
ResponseHTTP response
Createif True, create a session if no one exists
Returns
HTTP session

◆ GetWebComponentConfig()

IWebComponentConfig TdjGenericWebComponent::GetWebComponentConfig ( )

Returns a IWebComponentConfig object, which contains initialization parameters for this component.

Exceptions
EWebComponentExceptionif the method is called before the component has been initialized.

Implements IWebComponent.

◆ Init() [1/2]

TdjGenericWebComponent::Init ( )

A convenience method which can be overridden so that there is no need to call inherited Init(config).

◆ Init() [2/2]

TdjGenericWebComponent::Init ( const IWebComponentConfig Config)

Called by the container on startup.

Note
if this method is overridden, the overriding code must also call inherited Init.
Parameters
Configthe configuration
Exceptions
EWebComponentExceptionif initialization failed

Implements IWebComponent.

Referenced by ~TdjGenericWebComponent().

◆ Service()

TdjGenericWebComponent::Service ( TdjServerContext Context,
TdjRequest Request,
TdjResponse Response )

Handle a HTTP request.

The status code of the response always should be set for a component that throws or sends an error.

Note
a custom Web Component should not override this method.
Parameters
ContextHTTP server context
RequestHTTP request
ResponseHTTP response
Exceptions
EWebComponentExceptionif an exception occurs that interferes with the component's normal operation

Implements IWebComponent.

Member Data Documentation

◆ Config

IWebComponentConfig TdjGenericWebComponent::Config

Referenced by ~TdjGenericWebComponent().