Stuart Clennett 15 Posted January 4, 2019 (edited) Hi, I've tried adding a second app to my MARS rest engine (in order to support my api's version 2) as follows: class constructor TServerEngine.CreateEngine; var MyApp, MyApp2 : TMARSApplication; begin FEngine := TMARSEngine.Create; try // Engine configuration FEngine.Parameters.LoadFromIniFile; // Application configuration MyApp := FEngine.AddApplication('IBCSApp', '/ibcs', [ 'Server.Resources.*']); // Second Application (version 2 of the API) MyApp2 := FEngine.AddApplication('IBCSApp2', '/ibcs2', [ 'server2.Resources.*']); // [....] End; And I've created a server2.Resources.pas file into which I've added a simple "/healthcheck" resource that returns the server time as a string. I've also added this line initialization TMARSResourceRegistry.Instance.RegisterResource<THealthCheck>; But when the server runs, IBCSApp2 is shown in the list of engines, but it does not contain the /healthcheck resource. I should mention that the original app (IBCSApp) also has the same resource name (/healthcheck) implemented by a different class. I guess I am missing something? Thanks Stuart Edited January 4, 2019 by Stuart Clennett Share this post Link to post
Andrea Magni 75 Posted January 5, 2019 Hi, everything seems fine, just be sure your call to TMARSResourceRegistry.Instantce.RegisterResource<THealthCheck> takes place *before* the second call to AddApplication (in TServerEngine.CreateEngine method). I usually make this happen adding the name of the unit where THealthCheck to the uses clause list of the Server.Ignition.pas file (in the MARSTemplate demo, you can spot the Server.Resources unit listed there for the same reason). I am considering, in a future version of MARS, to switch from this 'initialization based' way of registering resources to a more 'configuration based' one. Still have to think about it and choose a simple approach to this problem. Sincerely, Andrea 1 Share this post Link to post
Stuart Clennett 15 Posted January 7, 2019 Thanks Andrea -- adding the server2.resources unit to the server.ignition.pas uses clause worked. Kind regards 1 Share this post Link to post