Added new features
Autocollection of API. Collects methods and its params and can be used as a draft. Works through Delphi RTTI methods.
Result looks like
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
--- TRPTests --- Exceptions | GET PostJson | POST URLEncoded | GET a: string b: string Sessions | GET MethodWithParams | GET aParam1: string aParam2: string HTTPAttribute | GET HTTPAttribute | POST aParam: string Create | GET Delete | GET Update | GET GetInfo | GET --- TRPFiles --- Upload | GET Download | GET Create | GET Delete | GET Update | GET GetInfo | GET --- TRPMemory --- CurrentProcessMemoryKB | GET CurrentProcessMemoryPeakKB | GET GetMemory | GET AContext: TIdContext ARequestInfo: TIdHTTPRequestInfo AResponseInfo: TIdHTTPResponseInfo --- TRPUsers --- Create | GET Delete | GET Update | GET GetInfo | GET Create | GET Delete | GET Update | GET GetInfo | GET |
how to use it ? in uRPApi in TRPApi.Get method just add classes that you need to be gathered as API draft. Like this
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
procedure TRPApi.Get; var fileName: string; api: ISP<TStringList>; filepath: string; begin fileName := 'api.txt'; if TFile.Exists(fileName) then TFile.Delete(fileName); api := TSP<TStringList>.Create(); CreateAPIFromClass(TRPTests, api); CreateAPIFromClass(TRPFiles, api); CreateAPIFromClass(TRPMemory, api); CreateAPIFromClass(TRPUsers, api); // add other classes that descendants from TRP or just API classes // CreateAPIFromClass(TRPOtherClass, api); api.SaveToFile(fileName); filepath := ExtractFileDir(Application.ExeName) + '\'+fileName; if TFile.Exists(filepath) then begin ResponseInfo.SmartServeFile(Context, RequestInfo, filepath); FResponses.OK(); end; end; |
Desktop or WindowsService modes. In Delphi *.dpr file we do like this
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
if (ParamCount > 0) and (ParamStr(1) = 'vcl_desktop') then begin Vcl.Forms.Application.Initialize; Vcl.Forms.Application.MainFormOnTaskbar := True; TStyleManager.TrySetStyle('Carbon'); Vcl.Forms.Application.CreateForm(TMain, Main); Main.IsVclDesktopMode := true; Vcl.Forms.Application.Run; end else begin if not Vcl.SvcMgr.Application.DelayInitialize or Vcl.SvcMgr.Application.Installing then Vcl.SvcMgr.Application.Initialize; Vcl.SvcMgr.Application.CreateForm(TDelphiRobustService, DelphiRobustService); Application.Run; end; |
Now if we need desktop we add param vcl_desktop, otherwise it will be compiled as service, which we can install and start like this in cmd
1 2 |
C:\Work\DSeattle\12_RobustServer\DelphiRobustServer\Win64\Debug\DelphiRobustServer.exe /install net start DelphiRobustService |