Hope you all had a great start of the year! 🙂
One frequent suggestion I got from developers willing to use MARS REST library is to make it as easier as possible to start from scratch.
These latest weeks I tried to follow this suggestion and tried to simplify some aspects here and there, for example:
- I added seamless integration for mORMot-JWT (no more errors trying authentication/authorization demos due to lack of OpenSSL libraries needed for the other library I was using for JWT implementation) so now (at least on Windows) you can simply compile and run most of the demos without glitches;
- I am working on an alternative implementation for the TMARSClient component innerly using TNetHttpClient and TNetHttpRequest to avoid deployment of OpenSSL (relying on platform’s http client implementation). Most work is already done and I am happy with backward compatibility as the only thing a developer will have to do to continue using the Indy implementation (TMARSClient) is to correct a unit in the uses clause (MARS.Client.Client.Indy versus MARS.Client.Client) and to switch to the new implementation it only requires to drop a new component (TMARSNetClient) and update the reference of the TMARSClientApplication components to the new TMARSNetClient. (I will blog post on this topic as soon as the new changes will be integrated into the master branch of MARS)
- I am expanding the JSON/record mapping here and there (last addition is multipart form data, including files from html forms). I hope to cover this topic soon in another blog post;
- I am trying to openly support Delphi edition lower than Enterprise one (like the Starter Edition to name one ;-)). Of course some very important features can’t be available in lower editions (think about FireDAC or Mobile/Linux support) but I think it is interesting to let Starter users to play with MARS (on Win32 platform, of course); (I will work more this direction and probably rearrange MARS packages accordingly)
- I created the MARScmd project (MARS\Utils\Source\MARScmd\MARScmd_VCL.dproj) an utility to kickstart a new MARS application project from scratch (cloning from Demos\MARSTemplate, for instance).
The MARSTemplate project is part of the Demos set of MARS library and it is intended to show how it is possible to implement a set of REST resources and applications and deploy the resulting application server using several different modalities, including: standalone VCL app, standalone FMX app, Windows service, Console application (Windows, Linux), Apache module (Windows, Linux), ISAPI dll. Each modality has a dedicated project (.dpr/.dproj) and there is a group project (.groupproj) including them all.
The structure of MARSTemplate is IMHO the best way to start your projects so till now I suggested to people to copy MARSTemplate and perform a global renaming replacing MARSTemplate to the name of their new project. This operation can be time consuming (due to the number of files interested) and it was not trivial to automate as it included search&replace into some files and also renaming of some other files. This is why I created MARScmd.
Just clone MARS (or Pull latest changes) and compile the MARScmd_VCL project (it is a simple VCL application that you should be able to compile with whatever Delphi version/edition), then run it. It should automatically determine the MARS base folder and the MARSTemplate folder:
You are allowed to have different templates if you like (simply select the right one clicking the apposite button near the edit with the template path) or click Next and go to the Options page.
Here you can specify the text to be searched and replaced, also you can state some patterns to match files whose content will be changed by MARScmd. Every file in the Template folder will be renamed (without considering the Matches parameter) if the text to be searched is in the file name but only those files with a name matching at least one pattern will have their content updated.
Last page will allow you to select a destination folder and finalize the operation. At the end, the newly created folder will be opened in a Windows shell where you should easily spot the .groupproj file. If you open it, you will have your MARS REST server project ready in the IDE.
You can easily compile all projects (click on the project group item in the Project Manager and select “Build all”. You can now run your project (the first in the project group, for example) and have your REST server up and running 🙂
I hope this little utility will be as handy for you as it is for me and I am open to suggestion for functionalities to be added to this utility (already have some ideas though).
Every screenshot in this blog post has been taken in VM running Delphi 10.2.2 (2004) Starter edition, if you are using Starter edition, the only change you will need to make is in the MARS.inc file (in the MARS\Source folder), commenting this line:
Stay tuned for more blog posts about MARS-Curiosity REST library! 🙂