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

Holds all known web component mappings for a context. More...

Inheritance diagram for TdjPathMap:

Public Member Functions

 AddUrlPattern (const string UrlPattern, TObject Value)
 Add a web component mapping.
 CheckExists (const string UrlPattern)
 Check if a mapping path exists.
TStrings GetMatches (const string Path)
 Return all matching mappings for the given path.
TSpecType GetSpecType (const string Spec)
Boolean Matches (const string Path, const string Spec)
 Matches the given path against a specified pattern.
Boolean Normalize (const string Target, string &Normalized)
 Canonicalizes a request target before routing.

Protected Member Functions

Boolean Matches (const string Path, const string Spec, TSpecType SpecType)
 Matches a given URL document path against a specified path pattern.

Detailed Description

Holds all known web component mappings for a context.

Matching is performed in the following order Exact match Longest prefix match Longest suffix match

Member Function Documentation

◆ AddUrlPattern()

TdjPathMap::AddUrlPattern ( const string UrlPattern,
TObject Value )

Add a web component mapping.

Parameters
UrlPatterna single component mapping path
Valuethe mapped web component
Exceptions
EDarajaMappingException

References Matches().

◆ CheckExists()

TdjPathMap::CheckExists ( const string UrlPattern)

Check if a mapping path exists.

This procedure throws a EDarajaMappingException if the URL pattern is already registered for this context.

Parameters
UrlPatterna single component mapping path
Exceptions
EDarajaMappingException

◆ GetMatches()

TStrings TdjPathMap::GetMatches ( const string Path)

Return all matching mappings for the given path.

The best match will be the first entry.

Parameters
Paththe URL path (without context
Returns
list of matching mappings

References GetSpecType(), Matches(), Normalize(), stDefault, stExact, stPrefix, stSuffix, and stUnknown.

◆ GetSpecType()

TSpecType TdjPathMap::GetSpecType ( const string Spec)
Parameters
Specthe path specification
Returns
the path specification type

Referenced by GetMatches().

◆ Matches() [1/2]

Boolean TdjPathMap::Matches ( const string Path,
const string Spec )

Matches the given path against a specified pattern.

Parameters
PathThe file or directory path to be checked.
SpecThe pattern or specification to match against.
Returns
True if the path matches the specification, otherwise False.

◆ Matches() [2/2]

Boolean TdjPathMap::Matches ( const string Path,
const string Spec,
TSpecType SpecType )
protected

Matches a given URL document path against a specified path pattern.

Parameters
Paththe URL document path
Specthe path specification
SpecTypethe path specification type
Returns
True if the Path matches the Spec (with known SpecType)

Referenced by AddUrlPattern(), and GetMatches().

◆ Normalize()

Boolean TdjPathMap::Normalize ( const string Target,
string & Normalized )

Canonicalizes a request target before routing.

Collapses ., .. and repeated / segments, and strips ;-delimited path parameters from each segment (e.g. /x.jsp;a=b -> /x.jsp), so that a filter and the component it guards – matched separately, but both against the result of this call – are guaranteed to see the same path. .. above the root is absorbed rather than rejected (it cannot escape the leading /). The result never has a trailing / unless it is the root path itself.

Parameters
Targetthe raw request target (already percent-decoded by Indy)
Normalizedthe canonicalized path, valid only if this function returns True
Returns
False if Target contains an embedded NUL or another raw control character (reject rather than normalize: this is not valid path input)

Referenced by GetMatches().