Code Monkey home page Code Monkey logo

mars's Introduction

MARS-curiosity logo

Delphi REST Library

  1. Lightweight
  2. Easy and powerful
  3. 100% RESTful Web Service
  4. Delphi-like
  5. Advanced dataset support with FireDAC
  6. OpenAPI 3 support

More features ...

Installation

  1. Clone or download this project
  2. Add folders to RAD Studio Library Path
  3. Build All in the RAD Studio IDE
  4. Install two packages

More about the installation ...

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:

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.

Documentation

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.

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:

COPYRIGHTS

  • The Delphi stylized helmet icon is trademark of Embarcadero Technologies.

mars's People

Contributors

andrea-magni avatar shaunroselt avatar davide675 avatar larsenbjorn avatar brov84 avatar lgldsilva avatar nandod avatar tino-teuber avatar mferlini avatar stuartclennett avatar daniela-zanini avatar dmlam avatar meg02in avatar kitesoft avatar ortuagustin avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.