-
Content Count
153 -
Joined
-
Last visited
-
Days Won
3
Andrea Magni last won the day on November 2 2020
Andrea Magni had the most liked content!
Community Reputation
80 ExcellentAbout Andrea Magni
- Birthday 05/24/1982
Technical Information
-
Delphi-Version
Delphi 10.4 Sydney
Recent Profile Visitors
-
Blog post: v.1.6 released with D13 support and new deployment option
Andrea Magni posted a topic in MARS-Curiosity REST Library
I've just released MARS v.1.6: among features and fixes, there is a new integration of WebBroker's FCGI support (added with Delphi 13, released yesterday). Read more at: https://blog.andreamagni.eu/2025/09/delphi-13-florence-and-mars-curiosity/ Sincerely, Andrea -
Generating an OpenAPI JSON doc from my MARS server
Andrea Magni replied to Stuart Clennett's topic in MARS-Curiosity REST Library
Hi @Stuart Clennett the mechanism is included in the MARSTemplate example, so you can have a look at it. (There is an OpenAPI button in the VCL application deployment mode). The descriptions can be added with an attribute-based mechanism (MetaDescription attribute, check MARS.Metadata.Attributes unit). Sincerely, Andrea -
Hide propertys for serialization/marshalling with the mars framework
Andrea Magni replied to mvanrijnen's topic in MARS-Curiosity REST Library
Hi @mvanrijnen, there is a JSONNameAttribute you can use to tweak serialization (and deserialization). Just decorate your field with JSONName('') to skip serialization/deserialization. If you need some logic, you can add a special method to your record type and it will be fired by the serialization/deserialization mechanism. The method should match this signature: TMyRecord.ToJSONFilter(const AMember: TRttiMember; const AObj: TJSONObject): Boolean; Just return False and implement your logic in the ToJSONFilter method. It is then up to you to add or not the value of AMember to the AObj that is being serialized. Sincerely, Andrea -
This feature (retrieving response content provided by the server even when an http error occurs) is now implemented in MARS client library. Check this demo: https://github.com/andrea-magni/MARS/tree/master/Demos/ErrorObjects BTW: I've also added a mechanism to implement this behavior on the server side. Sincerely, Andrea
-
Hi Stuart, have you generated your application using MARSCmd and selecting the MARSTemplate folder? I don't recognize that datamodule... BTW: MARS creates an instance of the resource per request. So if you have a TDatamodule descendant decorated with MARS attributes and registered as a REST resource, a new instance will be create per each incoming request. The TFDConnection, consequently, will be created too. The key point for using (FireDAC) connection pooling is pass through connection definition names (with Pooled parameter set to True) and not configuring the connection as one would do in a standalone application. Sincerely, Andrea
-
Andrea Magni changed their profile photo
-
JSON output/result changed with upgrade
Andrea Magni replied to bj2cs's topic in MARS-Curiosity REST Library
You can drive the serialization through the serialization options. Sincerely, Andrea -
Hi, what do you mean with "created the sample code"? I just pulled the most recent version from the repo, run MARSCmd_VCL and created a new project from the template. Everything compiles just fine Win32 and Win64 with my Delphi 12.1... Let me know how to reproduce the error. Sincerely, Andrea
-
How to even start? WSDL to REST
Andrea Magni replied to Robert Gilland's topic in MARS-Curiosity REST Library
Hi, now I get what you meant, sorry. To design your API in OpenAPI 3 format (for example) and to have the corresponding API implemented in MARS. This is something I'd like to add as a feature but I would say not in the immediate future. I've added (in the past) OpenAPI3 support to MARS, meaning the library will emit an OpenAPI3 description of your API (the other way around with respect to what you are asking). It would be a nice addition to cover your use case. I'll let you know if I'll find time to implement it (of course I would appreciate contribution as MARS is an OS project so if you feel to contribute, you are welcome!). Sincerely, Andrea -
How to even start? WSDL to REST
Andrea Magni replied to Robert Gilland's topic in MARS-Curiosity REST Library
Hi, you can start following instructions to install the library, if you haven't already. Check this link: https://github.com/andrea-magni/MARS/blob/master/docs/Installation.md After that, find, compile and run the MARSCmd utility ( Utils/Source/MARScmd folder in your repository clone). It will guide you through a simple wizard to startup your first MARS application, cloning the Demos/MARSTemplate project group. You should have your first MARS REST server application up and running in 1 minute. Sincerely, Andrea -
Bitdefender going crazy about with MARS compiles program
Andrea Magni replied to mvanrijnen's topic in MARS-Curiosity REST Library
Hi, I never faced this specific issue. I know for sure many people are successfully using MARS in different scenarios. Maybe this is a false positive (it happened more than once to see false positive with Delphi built software, even simple VCL applications). You may want to check the executable agains an online antivirus like virustotal or the like... Sincerely, Andrea -
Hi, yes you can easily read request's header: 1) using the HeaderParam attribute to decorate a field of your resource (or an argument of your method) to retrieve the value 2) accessing the IMARSActivation and the Request field to have a more direct access to the underlying request object Other thing is to use that header to provide authentication/authorization through MARS built-in facilities. We can explore that too, just let me know what you need and some examples of requests. Sincerely, Andrea
-
How to automatically delete temporary files using MARS
Andrea Magni replied to ertank's topic in MARS-Curiosity REST Library
Hello Ertan, you may want to check the AfterInvoke capabilities: - you can define a local method in your resource class that will be called after the request has been executed, yet before connection is closed; that seems a good place to cleanup temporary files - there is also a global mechanism ( look for TMARSActivation.RegisterAfterInvoke in Server.Ignition.pas in the MARSTemplate Demos folder). Hope this helps, let me know if you need something more. Sincerely, Andrea -
Log an error: [api] No implementation found for http method GET
Andrea Magni replied to KostasR's topic in MARS-Curiosity REST Library
Dear Kostas, firstly I want to apologize not being much available these months. I've been very busy and many things fell behind. The easiest way to log errors in MARS is to provide an InvokeError handler: TMARSActivation.RegisterInvokeError( procedure (const AActivation: IMARSActivation; const AException: Exception; var AHandled: Boolean) begin CodeSite.SendError('Error: ' + AException.Message + ' Path: ' + AActivation.URL.Path); end ); There is an (empty) example of this in Server.Ignition.pas unit of the MARSTemplate (Demos folder). Hope this helps! Sincerely, Andrea -
Hi @ertank, I managed to reply to your issue on GitHub: https://github.com/andrea-magni/MARS/issues/115 Sorry everybody for the late, I'll try to keep up with all questions ASAP. Sincerely, Andrea
-
How to iterate a TDictionary using RTTI and TValue
Andrea Magni replied to John Kouraklis's topic in Delphi IDE and APIs
I saw that too. I meant in the code above a genDictEnum.Free is missing somewhere before mc.Free call. Thanks