TROHttpApiDispatcher
Overview
The TROHttpApiDispatcher class provides possibility to serve HttpAPI (aka Swagger) requests.
Location
- Unit: uROHttpApiDispatcher.pas
- Ancestry: TComponent | TROComponent | TROExtendedHttpDispatcher | TROHttpApiDispatcher
constructor Create override
Standard component constructor
constructor Create(AOwner: TComponent)
Parameters:
- AOwner: Owner
Activate override
procedure Activate
ApiHost
property ApiHost: string read write
ApiName
property ApiName: string read write
ApiVersion
property ApiVersion: string read write
Assign override
procedure Assign(Source: TPersistent)
Parameters:
- Source:
AuthenticationManager
Adds possibility to call secure methods
property AuthenticationManager: TROHttpApiBaseAuthenticationManager read write
CanHandlePath (declared in TROExtendedHttpDispatcher)
Return true if the given path can be handled by the dispatcher. The function compares the Path property content with the given path and chacks if the given path starts with the Path subpath.
function CanHandlePath(aPath: string): Boolean
Parameters:
- aPath: The request path to check.
Deactivate override
procedure Deactivate
EventSinkSupport
Adds event sink support
property EventSinkSupport: Boolean read write default False
Notification protected override
Forwards notification messages to all owned components.
procedure Notification(AComponent: TComponent; Operation: TOperation)
Parameters:
- AComponent: component
- Operation: operation
NotifyDispose (declared in TROExtendedHttpDispatcher)
This procedure is called when the server HTTP channel is about to be freed.
procedure NotifyDispose
OnSchemaComplete
Fires when metadata generation is complete. Allows to modify generated metadata.
property OnSchemaComplete: TROHttpApiSchemaCompleteEvent read write
delegate: procedure OnSchemaComplete(const aRoot: TROJSONObject)
Path (declared in TROExtendedHttpDispatcher)
The request path the dispatcher will be activated for. For example, if this property contains /js then the dispatcher will be activated by the server channel to process such requests as http://example.org:8099/js/* (the asterisk means zero or more characters to continue the request path).
property Path: string read write
Process override
The main method to perform the request processing ant to form the response. Called every time to process incoming requests if the dispatcher is suitable to process it (determined by CanHandlePath result).
procedure Process(aTransport: IROHTTPTransport; aRequest: IROHTTPRequest; aResponse: IROHTTPResponse; aRequestData: TStream; aResponseData: TStream)
Parameters:
- aTransport: Http transport.
- aRequest: Contains object implementing IROHTTPRequest interface that describes the request.
- aResponse: Contains initialized object implementing IROHTTPResponse interface that should describe the response.
- aRequestData: The data stream (TStream) that contains the raw HTTP request data except the header part.
- aResponseData: Contais initialized and empty data stream (TStream) that shpuld be filled with the raw reponse data except the header part.
ResetCache
Resets internal cache. Can be usable when plugin system is used.
procedure ResetCache
ROFreeNotification (declared in TROComponent)
Forwards notification messages to all owned components.
procedure ROFreeNotification(aComponent: TComponent)
Parameters:
- aComponent: component
RORemoveFreeNotification (declared in TROComponent)
Forwards notification messages to all owned components.
procedure RORemoveFreeNotification(aComponent: TComponent)
Parameters:
- aComponent: component
SendRemoveNotification protected (declared in TROComponent)
Forwards notification messages to all owned components.
procedure SendRemoveNotification(aComponent: TComponent)
Parameters:
- aComponent: component
ServeMetaData
Allows to generate metadata
property ServeMetaData: Boolean read write default True
Server (declared in TROExtendedHttpDispatcher)
Points to the HTTP server channel which the dispatcher works with.
property Server: IROHTTPServer read write
ApiHost
property ApiHost: string read write
ApiName
property ApiName: string read write
ApiVersion
property ApiVersion: string read write
AuthenticationManager
Adds possibility to call secure methods
property AuthenticationManager: TROHttpApiBaseAuthenticationManager read write
EventSinkSupport
Adds event sink support
property EventSinkSupport: Boolean read write default False
Path (declared in TROExtendedHttpDispatcher)
The request path the dispatcher will be activated for. For example, if this property contains /js then the dispatcher will be activated by the server channel to process such requests as http://example.org:8099/js/* (the asterisk means zero or more characters to continue the request path).
property Path: string read write
ServeMetaData
Allows to generate metadata
property ServeMetaData: Boolean read write default True
Server (declared in TROExtendedHttpDispatcher)
Points to the HTTP server channel which the dispatcher works with.
property Server: IROHTTPServer read write
constructor Create override
Standard component constructor
constructor Create(AOwner: TComponent)
Parameters:
- AOwner: Owner
Activate override
procedure Activate
Assign override
procedure Assign(Source: TPersistent)
Parameters:
- Source:
CanHandlePath (declared in TROExtendedHttpDispatcher)
Return true if the given path can be handled by the dispatcher. The function compares the Path property content with the given path and chacks if the given path starts with the Path subpath.
function CanHandlePath(aPath: string): Boolean
Parameters:
- aPath: The request path to check.
Deactivate override
procedure Deactivate
Notification protected override
Forwards notification messages to all owned components.
procedure Notification(AComponent: TComponent; Operation: TOperation)
Parameters:
- AComponent: component
- Operation: operation
NotifyDispose (declared in TROExtendedHttpDispatcher)
This procedure is called when the server HTTP channel is about to be freed.
procedure NotifyDispose
Process override
The main method to perform the request processing ant to form the response. Called every time to process incoming requests if the dispatcher is suitable to process it (determined by CanHandlePath result).
procedure Process(aTransport: IROHTTPTransport; aRequest: IROHTTPRequest; aResponse: IROHTTPResponse; aRequestData: TStream; aResponseData: TStream)
Parameters:
- aTransport: Http transport.
- aRequest: Contains object implementing IROHTTPRequest interface that describes the request.
- aResponse: Contains initialized object implementing IROHTTPResponse interface that should describe the response.
- aRequestData: The data stream (TStream) that contains the raw HTTP request data except the header part.
- aResponseData: Contais initialized and empty data stream (TStream) that shpuld be filled with the raw reponse data except the header part.
ResetCache
Resets internal cache. Can be usable when plugin system is used.
procedure ResetCache
ROFreeNotification (declared in TROComponent)
Forwards notification messages to all owned components.
procedure ROFreeNotification(aComponent: TComponent)
Parameters:
- aComponent: component
RORemoveFreeNotification (declared in TROComponent)
Forwards notification messages to all owned components.
procedure RORemoveFreeNotification(aComponent: TComponent)
Parameters:
- aComponent: component
SendRemoveNotification protected (declared in TROComponent)
Forwards notification messages to all owned components.
procedure SendRemoveNotification(aComponent: TComponent)
Parameters:
- aComponent: component
OnSchemaComplete
Fires when metadata generation is complete. Allows to modify generated metadata.
property OnSchemaComplete: TROHttpApiSchemaCompleteEvent read write
delegate: procedure OnSchemaComplete(const aRoot: TROJSONObject)