mirror of
https://github.com/danieleteti/delphimvcframework.git
synced 2024-11-15 07:45:54 +01:00
Small improvements in id handling for jsonrpc requests
Some checks failed
TOC Generator / TOC Generator (push) Has been cancelled
Some checks failed
TOC Generator / TOC Generator (push) Has been cancelled
This commit is contained in:
parent
7186f6aa6f
commit
b1c2a87200
@ -6,7 +6,6 @@
|
|||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<script src="https://unpkg.com/htmx.org@latest"></script>
|
<script src="https://unpkg.com/htmx.org@latest"></script>
|
||||||
<script src="/static/js/main.js"></script>
|
|
||||||
<title>HTMX App</title>
|
<title>HTMX App</title>
|
||||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@picocss/pico@2/css/pico.min.css"
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@picocss/pico@2/css/pico.min.css"
|
||||||
/>
|
/>
|
||||||
|
@ -42,7 +42,6 @@ type
|
|||||||
private
|
private
|
||||||
function GetCustomersDataset: TFDMemTable;
|
function GetCustomersDataset: TFDMemTable;
|
||||||
procedure FillCustomersDataset(const DataSet: TDataSet);
|
procedure FillCustomersDataset(const DataSet: TDataSet);
|
||||||
// function GetPeopleDataset: TFDMemTable;
|
|
||||||
procedure FillPeopleDataset(const DataSet: TDataSet);
|
procedure FillPeopleDataset(const DataSet: TDataSet);
|
||||||
public
|
public
|
||||||
procedure OnBeforeRoutingHook(const Context: TWebContext; const JSON: TJDOJsonObject);
|
procedure OnBeforeRoutingHook(const Context: TWebContext; const JSON: TJDOJsonObject);
|
||||||
|
@ -1260,9 +1260,7 @@ var
|
|||||||
begin
|
begin
|
||||||
if JSON.Types[JSONRPC_ID] = jdtString then
|
if JSON.Types[JSONRPC_ID] = jdtString then
|
||||||
lReqID := JSON.S[JSONRPC_ID]
|
lReqID := JSON.S[JSONRPC_ID]
|
||||||
else if JSON.Types[JSONRPC_ID] = jdtInt then
|
else if JSON.Types[JSONRPC_ID] in [jdtInt, jdtLong] then
|
||||||
lReqID := JSON.I[JSONRPC_ID]
|
|
||||||
else if JSON.Types[JSONRPC_ID] = jdtLong then
|
|
||||||
lReqID := JSON.L[JSONRPC_ID]
|
lReqID := JSON.L[JSONRPC_ID]
|
||||||
else if JSON.Types[JSONRPC_ID] = jdtULong then
|
else if JSON.Types[JSONRPC_ID] = jdtULong then
|
||||||
lReqID := JSON.U[JSONRPC_ID]
|
lReqID := JSON.U[JSONRPC_ID]
|
||||||
@ -1271,21 +1269,6 @@ begin
|
|||||||
|
|
||||||
lMethodName := JSON.S[JSONRPC_METHOD];
|
lMethodName := JSON.S[JSONRPC_METHOD];
|
||||||
Result := TJSONRPCRequest.Create(lReqID, lMethodName);
|
Result := TJSONRPCRequest.Create(lReqID, lMethodName);
|
||||||
{
|
|
||||||
if JSON.Types[JSONRPC_PARAMS] = jdtArray then
|
|
||||||
begin
|
|
||||||
lParams := JSON.A[JSONRPC_PARAMS];
|
|
||||||
for I := 0 to lParams.Count - 1 do
|
|
||||||
begin
|
|
||||||
Result.Params.Add(JSONDataValueToTValue(lParams[I]));
|
|
||||||
end;
|
|
||||||
end
|
|
||||||
else if JSON.Types[JSONRPC_PARAMS] <> jdtNone then
|
|
||||||
begin
|
|
||||||
raise EMVCJSONRPCException.Create('Params must be a JSON array or null');
|
|
||||||
end;
|
|
||||||
|
|
||||||
}
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TMVCJSONRPCController.CreateResponse(const RequestID: TValue; const Value: TValue): TJSONRPCResponse;
|
function TMVCJSONRPCController.CreateResponse(const RequestID: TValue; const Value: TValue): TJSONRPCResponse;
|
||||||
@ -2343,16 +2326,14 @@ begin
|
|||||||
begin
|
begin
|
||||||
Result.S[JSONRPC_ID] := FID.AsString;
|
Result.S[JSONRPC_ID] := FID.AsString;
|
||||||
end
|
end
|
||||||
else if FID.IsType<Int32> then
|
|
||||||
begin
|
|
||||||
Result.I[JSONRPC_ID] := FID.AsInteger;
|
|
||||||
end
|
|
||||||
else if FID.IsType<Int64> then
|
else if FID.IsType<Int64> then
|
||||||
begin
|
begin
|
||||||
Result.I[JSONRPC_ID] := FID.AsInt64;
|
Result.L[JSONRPC_ID] := FID.AsInt64;
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
begin
|
||||||
raise EMVCJSONRPCException.Create('ID can be only Int32, Int64 or String');
|
raise EMVCJSONRPCException.Create('ID can be only Int32, Int64 or String');
|
||||||
|
end;
|
||||||
|
|
||||||
try
|
try
|
||||||
if Assigned(FError) then
|
if Assigned(FError) then
|
||||||
|
Loading…
Reference in New Issue
Block a user