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

A base class which can be subclassed to create a HTTP filter component for a Web site. More...

Inheritance diagram for TdjWebFilter:
TdjGenericWebFilter IWebFilter TdjWebFilterHolder TdjWebFilterHolders

Public Member Functions

 TdjWebFilter ()
 DestroyFilter ()
 Called when filter is being removed from service.
 DoFilter (TdjServerContext Context, TdjRequest Request, TdjResponse Response, const IWebFilterChain Chain)
 The DoFilter method of the Filter is called by the container each time a request/response pair is passed through the chain due to a client request for a resource at the end of the chain.
IWebFilterConfig GetWebFilterConfig ()
 Returns the configuration for this filter.
 Init ()
 A convenience method which can be overridden so that there is no need to call inherited Init(config).
 Init (const IWebFilterConfig Config)
 Called by the container on startup.

Public Attributes

IWebFilterConfig Config

Detailed Description

A base class which can be subclassed to create a HTTP filter component for a Web site.

Note
Threading: as with TdjWebComponent, the framework creates exactly one instance of each registered filter, and every concurrent request runs through that same instance's DoFilter method on its own thread. Do not keep per-request state in instance fields — two requests handled at the same time will read and write the same field, corrupting each other's data. Use local variables for anything request-specific, and if state truly must be shared across requests, synchronize access to it explicitly (e.g. with a critical section).
URL patterns are not authorization. A filter mapped to a prefix or suffix pattern (e.g. everything under '/admin/') is a routing rule, matched after the framework normalizes the request path (collapsing '.', '..' and repeated '/', and stripping ';'-parameters) – but it says nothing about who the caller is. An authentication/authorization filter must still check the caller's identity itself (e.g. the session) before allowing a request through, rather than relying on the URL pattern alone to gate access.

Constructor & Destructor Documentation

◆ TdjWebFilter()

TdjWebFilter::TdjWebFilter ( )

Member Function Documentation

◆ DestroyFilter()

TdjGenericWebFilter::DestroyFilter ( )
inherited

Called when filter is being removed from service.

Note
This method can be overridden in descendant classes to implement custom cleanup logic for the filter.

Implements IWebFilter.

References Config, and GetWebFilterConfig().

◆ DoFilter()

TdjGenericWebFilter::DoFilter ( TdjServerContext Context,
TdjRequest Request,
TdjResponse Response,
const IWebFilterChain Chain )
inherited

The DoFilter method of the Filter is called by the container each time a request/response pair is passed through the chain due to a client request for a resource at the end of the chain.

Parameters
ContextThe server context for this request
RequestThe HTTP request being processed
ResponseThe HTTP response being generated
ChainThe filter chain to pass the request/response to

Implements IWebFilter.

◆ GetWebFilterConfig()

IWebFilterConfig TdjGenericWebFilter::GetWebFilterConfig ( )
inherited

Returns the configuration for this filter.

Returns
The filter configuration object
Exceptions
EDarajaLifecycleExceptionif the filter is not initialized

Referenced by DestroyFilter().

◆ Init() [1/2]

TdjGenericWebFilter::Init ( )
inherited

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

◆ Init() [2/2]

TdjGenericWebFilter::Init ( const IWebFilterConfig Config)
inherited

Called by the container on startup.

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

Implements IWebFilter.

References Init().

Referenced by Init().

Member Data Documentation

◆ Config

IWebFilterConfig TdjGenericWebFilter::Config
inherited

Referenced by DestroyFilter().