mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-07 13:30:33 +02:00
* Move conversion of handler(def) to JSON Object to separatr, virtual methods
git-svn-id: trunk@19002 -
This commit is contained in:
parent
7e88628b02
commit
8fd9e8ea29
@ -36,6 +36,9 @@ Type
|
||||
Function FindHandler(Const AClassName,AMethodName : TJSONStringType;AContext : TJSONRPCCallContext; Out FreeObject : TComponent) : TCustomJSONRPCHandler; override;
|
||||
// Add type field
|
||||
function CreateJSON2Error(Const AMessage : String; Const ACode : Integer; ID : TJSONData = Nil; idname : TJSONStringType = 'id' ) : TJSONObject; override;
|
||||
// Create API method description
|
||||
Function HandlerToAPIMethod (H: TCustomJSONRPCHandler): TJSONObject; virtual;
|
||||
Function HandlerDefToAPIMethod (H: TJSONRPCHandlerDef): TJSONObject; virtual;
|
||||
// Create API
|
||||
Function DoAPI : TJSONData; virtual;
|
||||
// Namespace for API description. Must be set. Default 'FPWeb'
|
||||
@ -209,6 +212,17 @@ begin
|
||||
TJSONObject(Result).Add('type','rpc');
|
||||
end;
|
||||
|
||||
function TCustomExtDirectDispatcher.HandlerToAPIMethod(H: TCustomJSONRPCHandler): TJSONObject;
|
||||
begin
|
||||
Result:=TJSONObject.Create(['name',H.Name,'len',H.ParamDefs.Count])
|
||||
end;
|
||||
|
||||
function TCustomExtDirectDispatcher.HandlerDefToAPIMethod(H: TJSONRPCHandlerDef
|
||||
): TJSONObject;
|
||||
begin
|
||||
Result:=TJSONObject.Create(['name',H.HandlerMethodName,'len',H.ArgumentCount])
|
||||
end;
|
||||
|
||||
function TCustomExtDirectDispatcher.DoAPI: TJSONData;
|
||||
|
||||
Var
|
||||
@ -242,7 +256,7 @@ begin
|
||||
A.Add(N,R);
|
||||
end;
|
||||
H:=Owner.Components[i] as TCustomJSONRPCHandler;
|
||||
R.Add(TJSONObject.Create(['name',H.Name,'len',H.ParamDefs.Count]));
|
||||
R.Add(HandlerToAPIMethod(H));
|
||||
end;
|
||||
end;
|
||||
If (jdoSearchRegistry in Options) then
|
||||
@ -266,7 +280,7 @@ begin
|
||||
else
|
||||
R:=A.Items[J] as TJSONArray;
|
||||
end;
|
||||
R.Add(TJSONObject.Create(['name',HD.HandlerMethodName,'len',HD.ArgumentCount]));
|
||||
R.Add(HandlerDefToAPIMethod(HD));
|
||||
end;
|
||||
end;
|
||||
Result:=D;
|
||||
|
Loading…
Reference in New Issue
Block a user