Class TBrookRouter

Unit

Declaration

type TBrookRouter = class(TBrookComponent)

Description

Provides features for the route handling.

Hierarchy

Overview

Methods

Protected function CreateRoutes: TBrookRoutes; virtual;
Protected procedure FreeRoutes(ARoutes: TBrookRoutes); virtual;
Protected function CreateAction(out AActionClass: TBrookActionClass; ARequest: TBrookRequest; AResponse: TBrookResponse): TBrookAction; virtual;
Protected procedure FreeAction(AAction: TBrookAction); virtual;
Protected procedure ExecuteAction(AAction: TBrookAction; ARequest: TBrookRequest; AResponse: TBrookResponse; const ANames, AValues: TBrookArrayOfString; ARoute: TBrookRoute); overload; virtual;
Public constructor Create(AOwner: TComponent); override;
Public destructor Destroy; override;
Public class function GetServiceClass: TBrookRouterClass;
Public class procedure RegisterService;
Public class procedure UnregisterService;
Public class function Service: TBrookRouter;
Public class function RootUrl: string;
Public class function RootUrl(ARequest: TBrookRequest): string;
Public class procedure MethodNotAllowed(AResponse: TBrookResponse);
Public function UrlFor(AActionClass: TBrookActionClass; const AParams: array of string): string; overload;
Public function UrlFor(AClassName: string; const AParams: array of string): string; overload;
Public function Canonicalize(ARequest: TBrookRequest; AResponse: TBrookResponse): Boolean;
Public function MatchPattern(APattern, APathInfo: string; out ARedirect: Boolean; out ANames, AValues: TBrookArrayOfString): Boolean; virtual;
Public procedure Route(ARequest: TBrookRequest; AResponse: TBrookResponse); virtual;

Properties

Public property Routes: TBrookRoutes read FRoutes write FRoutes;
Public property AfterExecuteAction: TBrookExecuteActionEvent read FAfterExecuteAction write FAfterExecuteAction;
Public property AfterMatchPattern: TBrookMatchPatternEvent read FAfterMatchPattern write FAfterMatchPattern;
Public property AfterRoute: TBrookRouteEvent read FAfterRoute write FAfterRoute;
Public property BeforeExecuteAction: TBrookExecuteActionEvent read FBeforeExecuteAction write FBeforeExecuteAction;
Public property BeforeMatchPattern: TBrookMatchPatternEvent read FBeforeMatchPattern write FBeforeMatchPattern;
Public property BeforeRoute: TBrookRouteEvent read FBeforeRoute write FBeforeRoute;

Description

Methods

Protected function CreateRoutes: TBrookRoutes; virtual;
 
Protected procedure FreeRoutes(ARoutes: TBrookRoutes); virtual;
 
Protected function CreateAction(out AActionClass: TBrookActionClass; ARequest: TBrookRequest; AResponse: TBrookResponse): TBrookAction; virtual;
 
Protected procedure FreeAction(AAction: TBrookAction); virtual;
 
Protected procedure ExecuteAction(AAction: TBrookAction; ARequest: TBrookRequest; AResponse: TBrookResponse; const ANames, AValues: TBrookArrayOfString; ARoute: TBrookRoute); overload; virtual;
 
Public constructor Create(AOwner: TComponent); override;

Creates an instance of a TBrookRouter class.

Public destructor Destroy; override;

Frees an instance of TBrookRouter class.

Public class function GetServiceClass: TBrookRouterClass;

Return the service class provided by this class.

Public class procedure RegisterService;

Registers the service provided by this class.

Public class procedure UnregisterService;

Unregisters the service provided by this class.

Public class function Service: TBrookRouter;

Return an instance of this class.

Public class function RootUrl: string;

Return the root URL.

Public class function RootUrl(ARequest: TBrookRequest): string;

Return the root URL passing TBrookRequest as param.

Public class procedure MethodNotAllowed(AResponse: TBrookResponse);

Sends the HTTP "NotAllowed" status code to the response.

Public function UrlFor(AActionClass: TBrookActionClass; const AParams: array of string): string; overload;

Creates an URL for an action informing an array of parameters. Exemple:

@(longcode
      procedure TMyAction.Get;
      begin
        // When calling with http://localhost/cgi-bin/cgi1/foo/myvalue
        // the output will be /cgi-bin/cgi1/foo/myvalue
        Write(UrlFor(TMyAction, ['myvalue']));
      end;

      initialization
        TMyAction.Register('/foo/:myvar');)

Public function UrlFor(AClassName: string; const AParams: array of string): string; overload;

Creates an URL for an action passing an array of parameters however informing the class name as string

Public function Canonicalize(ARequest: TBrookRequest; AResponse: TBrookResponse): Boolean;

Adds an slash to the end of the URL if does not exist.

Public function MatchPattern(APattern, APathInfo: string; out ARedirect: Boolean; out ANames, AValues: TBrookArrayOfString): Boolean; virtual;

Checks if the given parameters match with a registered route.

Public procedure Route(ARequest: TBrookRequest; AResponse: TBrookResponse); virtual;

Runs the route processing.

Properties

Public property Routes: TBrookRoutes read FRoutes write FRoutes;

List of available routes.

Public property AfterExecuteAction: TBrookExecuteActionEvent read FAfterExecuteAction write FAfterExecuteAction;

Is triggered after the router executes a action.

Public property AfterMatchPattern: TBrookMatchPatternEvent read FAfterMatchPattern write FAfterMatchPattern;

Is triggered after the router matches a pattern.

Public property AfterRoute: TBrookRouteEvent read FAfterRoute write FAfterRoute;

Is triggered after the router is routing.

Public property BeforeExecuteAction: TBrookExecuteActionEvent read FBeforeExecuteAction write FBeforeExecuteAction;

Is triggered before the router executes a action.

Public property BeforeMatchPattern: TBrookMatchPatternEvent read FBeforeMatchPattern write FBeforeMatchPattern;

Is triggered before the router matches a pattern.

Public property BeforeRoute: TBrookRouteEvent read FBeforeRoute write FBeforeRoute;

Is triggered before the router is routing.


Generated by PasDoc 0.15.0.