Class TBrookURLRouter

Unit

Declaration

type TBrookURLRouter = class(TBrookHandledComponent)

Description

URL router component.

Hierarchy

Overview

Methods

Public constructor Create(AOwner: TComponent); override;
Public destructor Destroy; override;
Public function GetEnumerator: TBrookURLRoutesEnumerator;
Public function Add: TBrookURLRoute; inline;
Public procedure Remove(const APattern: string); inline;
Public procedure Clear; inline;
Public procedure Open;
Public procedure Close;
Public procedure Route(ASender: TObject; const APath: string; ARequest: TBrookHTTPRequest; AResponse: TBrookHTTPResponse); overload; virtual;
Public procedure Route(ASender: TObject; ARequest: TBrookHTTPRequest; AResponse: TBrookHTTPResponse); overload; virtual;

Properties

Public property Items[AIndex:Integer]: TBrookURLRoute read GetItem write SetItem;
Published property Active: Boolean read FActive write SetActive stored IsActiveStored;
Published property Routes: TBrookURLRoutes read FRoutes write SetRoutes;
Published property OnRoute: TBrookURLRouterRouteEvent read FOnRoute write FOnRoute;
Published property OnNotFound: TBrookURLRouterRouteEvent read FOnNotFound write FOnNotFound;
Published property OnActivate: TNotifyEvent read FOnActivate write FOnActivate;
Published property OnDeactivate: TNotifyEvent read FOnDeactivate write FOnDeactivate;

Description

Methods

Public constructor Create(AOwner: TComponent); override;

Creates an instance of TBrookURLRouter.

Parameters
AOwner[in]
Owner component.
Public destructor Destroy; override;

Destroys an instance of TBrookURLRouter.

Public function GetEnumerator: TBrookURLRoutesEnumerator;

Creates an enumerator to iterate the routes through for..in.

Public function Add: TBrookURLRoute; inline;

Adds a new item to the routes list.

Returns

Route item.

Public procedure Remove(const APattern: string); inline;

Removes an item from the routes list by its pattern.

Parameters
APattern[in]
Route name.
Public procedure Clear; inline;

Clears the routes list.

Public procedure Open;

Enabled the router component.

Public procedure Close;

Disables the router component.

Public procedure Route(ASender: TObject; const APath: string; ARequest: TBrookHTTPRequest; AResponse: TBrookHTTPResponse); overload; virtual;

Routes a request passing a given path.

Parameters
ASender[in]
Sender object.
APath[in]
Route path.
ARequest[in]
Request object.
AResponse[in]
Response object.
Public procedure Route(ASender: TObject; ARequest: TBrookHTTPRequest; AResponse: TBrookHTTPResponse); overload; virtual;

Routes a request obtaining path from the request object.

Parameters
ASender[in]
Sender object.
ARequest[in]
Request object.
AResponse[in]
Response object.

Properties

Public property Items[AIndex:Integer]: TBrookURLRoute read GetItem write SetItem;

Gets/sets a route from/to the routes list by its index.

Published property Active: Boolean read FActive write SetActive stored IsActiveStored;

Enabled/disables the router component.

Published property Routes: TBrookURLRoutes read FRoutes write SetRoutes;

Available routes list.

Published property OnRoute: TBrookURLRouterRouteEvent read FOnRoute write FOnRoute;

Event triggered when the router dispatches a route.

Published property OnNotFound: TBrookURLRouterRouteEvent read FOnNotFound write FOnNotFound;

Event triggered when a route is not found.

Published property OnActivate: TNotifyEvent read FOnActivate write FOnActivate;

Event triggered when the router component is enabled.

Published property OnDeactivate: TNotifyEvent read FOnDeactivate write FOnDeactivate;

Event triggered when the router component is disabled.


Generated by PasDoc 0.16.0.