glprog / MiniREST

Simple Delphi REST Server

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MiniREST

Create a simple REST server using Delphi

Example

THelloWorldController = class(TMiniRESTControllerBase)
public
  [RequestMapping('/hello')]
  procedure Hello;
  [RequestMapping('/hello/{name}')]
  procedure HelloWithPathVariable;
end;

procedure THelloWorldController.Hello;
begin
  Response('Hello World!');
end;

procedure THelloWorldController.HelloWithPathVariable;
begin
  Response('Hello ' + PathVariable('name'));
end;

procedure TForm1.btnStartClick(Sender: TObject);
begin
  FMiniRESTServer := TMiniRESTServerIndy.Create;
  FMiniRESTServer.AddController(THelloWorldController);
  FMiniRESTServer.SetPort(StrToIntDef(edtPort.Text, 8080));
  FMiniRESTServer.Start;
end;

About

Simple Delphi REST Server


Languages

Language:Pascal 95.5%Language:PHP 3.8%Language:JavaScript 0.5%Language:Batchfile 0.2%Language:HTML 0.0%