Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/andrea-magni/MARS
MARS-Curiosity Delphi REST Library
https://github.com/andrea-magni/MARS
delphi rest
Last synced: about 1 month ago
JSON representation
MARS-Curiosity Delphi REST Library
- Host: GitHub
- URL: https://github.com/andrea-magni/MARS
- Owner: andrea-magni
- License: mpl-2.0
- Created: 2016-01-21T07:15:15.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2024-03-01T15:36:26.000Z (4 months ago)
- Last Synced: 2024-05-01T20:32:59.822Z (about 2 months ago)
- Topics: delphi, rest
- Language: Pascal
- Homepage:
- Size: 28.5 MB
- Stars: 356
- Watchers: 73
- Forks: 111
- Open Issues: 26
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: docs/CODE_OF_CONDUCT.md
Lists
- awesome-pascal - MARS - Curiosity
- awesome-delphi - MARS - Curiosity
- awesome-delphi - MARS - Curiosity
README
![](https://img.shields.io/github/v/release/andrea-magni/MARS)
![](https://img.shields.io/github/release-date/andrea-magni/MARS)
![](https://img.shields.io/github/commits-since/andrea-magni/MARS/v1.5)![MARS-curiosity logo](media/logo-small-MARS.png)
# Delphi REST Library
1. Lightweight
1. Easy and powerful
1. 100% RESTful Web Service
1. Delphi-like
1. Advanced dataset support with FireDAC
1. OpenAPI 3 support[More features ...](./docs/MainFeatures.md)
# Installation
1. Clone or download this project
1. Add folders to RAD Studio Library Path
1. Build All in the RAD Studio IDE
1. Install two packages[More about the installation ...](docs/Installation.md)
# Use the Code Luke!
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:
```pascal
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;
// ----------------------------------
// 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.
```# Documentation
* [Andrea Magni Blog](http://www.andreamagni.eu)
* [More demos and templates](./docs/Demos.md)* [MARS Documentation Page](./docs/README.md) TBD
## Forum
Official MARS Curiosity forum at Delphi-Praxis International: https://en.delphipraxis.net/forum/34-mars-curiosity-rest-library/
# Contribution
It would be great if you would like to support this project. It's quite easy and you can became better Gitter then.
* [See Contribution Guide](./CONTRIBUTING.md)
# Thanks
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.
# Related Links
Embarcadero Delphi is a modern, powerful and effective language and development tool. Learn more about it at the following links:
* https://www.embarcadero.com/
* https://learndelphi.org/# COPYRIGHTS
* The Delphi stylized helmet icon is trademark of Embarcadero Technologies.