- Lightweight
- Easy and powerful
- 100% RESTful Web Service
- Delphi-like
- Advanced dataset support with FireDAC
- Clone or download this project
- Add folders to RAD Studio Library Path
- Build All in the RAD Studio IDE
- Install two packages
More about the installation ...
Build REST server with MARS Curiosity is very easy. To run a simple REST server just create a new Console Application and use the following code:
program Mars1;
{$APPTYPE CONSOLE}
{$R *.res}
uses
System.SysUtils,
MARS.Core.Engine,
MARS.http.Server.Indy,
MARS.mORMotJWT.Token,
MARS.Core.MessageBodyWriters,
MARS.Core.Attributes,
MARS.Core.MediaType,
MARS.Core.Registry;
type
[Path('helloworld')]
THelloWorldResource = class
public
[GET, Produces(TMediaType.TEXT_PLAIN)]
function SayHelloWorld: string;
end;
function THelloWorldResource.SayHelloWorld: string;
begin
Result := 'Hello World! Here is MARS Curiosity ...';
end;
var
FEngine: MARS.Core.Engine.TMARSEngine;
FServer: MARS.http.Server.Indy.TMARShttpServerIndy;
begin
// ----------------------------------
// Register a resource class
MARS.Core.Registry.TMARSResourceRegistry.Instance.
RegisterResource<THelloWorldResource>;
// ----------------------------------
// Build and configure the engine
FEngine := MARS.Core.Engine.TMARSEngine.Create;
FEngine.BasePath := '/rest';
FEngine.Port := 8080;
FEngine.AddApplication('DefaultAPI', '/default', ['*.THelloWorldResource']);
FServer := MARS.http.Server.Indy.TMARShttpServerIndy.Create(FEngine);
// ----------------------------------
// Run the REST server
FServer.Active := True;
Writeln ('Server is running ...');
Write ('Press Enter to stop ...');
Readln;
// ----------------------------------
// Close the server
FServer.Active := False;
FreeAndNil(FServer);
FreeAndNil(FEngine);
end.
Official MARS Curiosity forum at Delphi-Praxis International: https://en.delphipraxis.net/forum/34-mars-curiosity-rest-library/
It would be great if you would like to support this project. It's quite easy and you can became better Gitter then.
Most of the code has been written by the author (Andrea Magni) with some significant contributions by Nando Dessena, Stefan Glienke and Davide Rossi. Some of my customers actually act as beta testers and early adopters. I want to thank them all for the trust and effort.
- The Delphi stylized helmet icon is trademark of Embarcadero Technologies.