mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-10-22 10:01:33 +02:00
* Introduce ExecuteHandler in dispatcher, allows overriding
git-svn-id: trunk@28191 -
This commit is contained in:
parent
c3f24cc775
commit
0a220476a3
@ -151,10 +151,11 @@ Type
|
||||
FOnStartBatch: TNotifyEvent;
|
||||
FOptions: TJSONRPCDispatchOptions;
|
||||
Protected
|
||||
|
||||
// Find handler. If none found, nil is returned. Executes OnFindHandler if needed.
|
||||
// On return 'DoFree' must be set to indicate that the hand
|
||||
Function FindHandler(Const AClassName,AMethodName : TJSONStringType;AContext : TJSONRPCCallContext; Out FreeObject : TComponent) : TCustomJSONRPCHandler; virtual;
|
||||
// Execute handler instance. This can be overridden to implement e.g. authentication globally before actually executing the handler.
|
||||
Function ExecuteHandler(H: TCustomJSONRPCHandler; Params, ID: TJSONData; AContext: TJSONRPCCallContext): TJSONData; virtual;
|
||||
// Execute method. Finds handler, and returns response.
|
||||
Function ExecuteMethod(Const AClassName, AMethodName : TJSONStringType; Params,ID : TJSONData; AContext : TJSONRPCCallContext) : TJSONData; virtual;
|
||||
// Check and Execute a single request. Exceptions are caught and converted to request error object.
|
||||
@ -720,6 +721,11 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
Function TCustomJSONRPCDispatcher.ExecuteHandler(H : TCustomJSONRPCHandler; Params,ID: TJSONData;AContext : TJSONRPCCallContext): TJSONData;
|
||||
begin
|
||||
Result:=H.Execute(Params,AContext);
|
||||
end;
|
||||
|
||||
function TCustomJSONRPCDispatcher.ExecuteMethod(Const AClassName,AMethodName: TJSONStringType;
|
||||
Params,ID: TJSONData;AContext : TJSONRPCCallContext): TJSONData;
|
||||
|
||||
@ -737,7 +743,7 @@ begin
|
||||
try
|
||||
If Assigned(FOndispatchRequest) then
|
||||
FOndispatchRequest(Self,AClassName,AMethodName,Params);
|
||||
Result:=H.Execute(Params,AContext);
|
||||
Result:=ExecuteHandler(H,Params,ID,AContext);
|
||||
finally
|
||||
If Assigned(FreeObject) then
|
||||
FreeAndNil(FreeObject);
|
||||
|
Loading…
Reference in New Issue
Block a user