Skip to content

Kitto.Web.Routes ​

Routing infrastructure for KittoX. Defines the composable route hierarchy (abstract TKWebRoute with before/after event hooks, the static-file routes, and the TKWebRouteList composite that dispatches to its children) used by the web engine to match and serve requests.

IKWebHandleRequestEventListener interface ​

Listener notified before and after a route handles a request. Subscribers can veto a request (BeforeHandleRequest) or react to its outcome (AfterHandleRequest).

pascal
procedure BeforeHandleRequest(const ASender: TKWebRoute;

Fired before a route handles a request; set AIsAllowed := False to veto it.

pascal
procedure AfterHandleRequest(const ASender: TKWebRoute;

Fired after a route handled a request (AIsFatalError flags a fatal error).

TKWebRoute class ​

Abstract route. Handles requests for a class of paths.

pascal
procedure AddSubscriber(const ASubscriber: IKWebHandleRequestEventListener);

Adds a before/after handle-request event listener.

pascal
procedure RemoveSubscriber(const ASubscriber: IKWebHandleRequestEventListener);

Removes a previously added event listener.

pascal
function HandleRequest(const ARequest: TKWebRequest;

Handles a request; if handled, returns True (and sets the reponse up) if handled.

pascal
procedure AddedTo(const AList: TKWebRouteList;

Called when the route is added to a list. May be used to add dependant routes. The predefined implementation does nothing.

TKBaseStaticWebRoute class ​

Base class for routes that serve local files from the file system.

TKStaticWebRoute class ​

A route that serves requests for paths matching a specified pattern, providing local files from the file system.

pascal
constructor Create(const APattern, APath: string);

Creates the route serving files under APath for URLs matching APattern.

TKMultipleStaticWebRoute class ​

A route that serves requests for paths matching a specified pattern, looking through an ordered list of local paths and serving the first file it finds.

pascal
constructor Create(const ABasePath: string;

Creates the route serving URLs under ABasePath from the first matching file across the ordered ALocalPaths list.

TKWebRouteList class ​

A route that owns a list of routes and handles a request by passing it to its contained routes until one of them supports and handles it.

pascal
function AddRoute(const ARoute: TKWebRoute;

Adds a child route at AIndex (-1 = append) and returns it; the list owns it.

Released under Apache License, Version 2.0.