mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-18 10:32:14 +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;
|
Function FindHandler(Const AClassName,AMethodName : TJSONStringType;AContext : TJSONRPCCallContext; Out FreeObject : TComponent) : TCustomJSONRPCHandler; override;
|
||||||
// Add type field
|
// Add type field
|
||||||
function CreateJSON2Error(Const AMessage : String; Const ACode : Integer; ID : TJSONData = Nil; idname : TJSONStringType = 'id' ) : TJSONObject; override;
|
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
|
// Create API
|
||||||
Function DoAPI : TJSONData; virtual;
|
Function DoAPI : TJSONData; virtual;
|
||||||
// Namespace for API description. Must be set. Default 'FPWeb'
|
// Namespace for API description. Must be set. Default 'FPWeb'
|
||||||
@ -209,6 +212,17 @@ begin
|
|||||||
TJSONObject(Result).Add('type','rpc');
|
TJSONObject(Result).Add('type','rpc');
|
||||||
end;
|
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;
|
function TCustomExtDirectDispatcher.DoAPI: TJSONData;
|
||||||
|
|
||||||
Var
|
Var
|
||||||
@ -242,7 +256,7 @@ begin
|
|||||||
A.Add(N,R);
|
A.Add(N,R);
|
||||||
end;
|
end;
|
||||||
H:=Owner.Components[i] as TCustomJSONRPCHandler;
|
H:=Owner.Components[i] as TCustomJSONRPCHandler;
|
||||||
R.Add(TJSONObject.Create(['name',H.Name,'len',H.ParamDefs.Count]));
|
R.Add(HandlerToAPIMethod(H));
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
If (jdoSearchRegistry in Options) then
|
If (jdoSearchRegistry in Options) then
|
||||||
@ -266,7 +280,7 @@ begin
|
|||||||
else
|
else
|
||||||
R:=A.Items[J] as TJSONArray;
|
R:=A.Items[J] as TJSONArray;
|
||||||
end;
|
end;
|
||||||
R.Add(TJSONObject.Create(['name',HD.HandlerMethodName,'len',HD.ArgumentCount]));
|
R.Add(HandlerDefToAPIMethod(HD));
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
Result:=D;
|
Result:=D;
|
||||||
|
Loading…
Reference in New Issue
Block a user