mirror of
https://github.com/danieleteti/delphimvcframework.git
synced 2024-11-16 00:05:53 +01:00
80a0bc8f8c
ObjectMappers DataSetToObject support boolean types Sample\SoapRest Example application server providing both SOAP and REST webservices
84 lines
1.8 KiB
ObjectPascal
84 lines
1.8 KiB
ObjectPascal
unit frmServerU;
|
|
|
|
interface
|
|
|
|
uses
|
|
Winapi.Messages, System.SysUtils, System.Variants,
|
|
System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs,
|
|
Vcl.AppEvnts, Vcl.StdCtrls, IdHTTPWebBrokerBridge, Web.HTTPApp;
|
|
|
|
type
|
|
TForm1 = class(TForm)
|
|
ButtonStart: TButton;
|
|
ButtonStop: TButton;
|
|
EditPort: TEdit;
|
|
Label1: TLabel;
|
|
ApplicationEvents: TApplicationEvents;
|
|
ButtonOpenBrowser: TButton;
|
|
procedure FormCreate(Sender: TObject);
|
|
procedure ApplicationEventsIdle(Sender: TObject; var Done: Boolean);
|
|
procedure ButtonStartClick(Sender: TObject);
|
|
procedure ButtonStopClick(Sender: TObject);
|
|
procedure ButtonOpenBrowserClick(Sender: TObject);
|
|
private
|
|
FServer: TIdHTTPWebBrokerBridge;
|
|
procedure StartServer;
|
|
{ Private declarations }
|
|
public
|
|
{ Public declarations }
|
|
end;
|
|
|
|
var
|
|
Form1: TForm1;
|
|
|
|
implementation
|
|
|
|
{$R *.dfm}
|
|
|
|
uses
|
|
Winapi.Windows, Winapi.ShellApi;
|
|
|
|
procedure TForm1.ApplicationEventsIdle(Sender: TObject; var Done: Boolean);
|
|
begin
|
|
ButtonStart.Enabled := not FServer.Active;
|
|
ButtonStop.Enabled := FServer.Active;
|
|
EditPort.Enabled := not FServer.Active;
|
|
end;
|
|
|
|
procedure TForm1.ButtonOpenBrowserClick(Sender: TObject);
|
|
var
|
|
LURL: string;
|
|
begin
|
|
StartServer;
|
|
LURL := Format('http://localhost:%s', [EditPort.Text]);
|
|
ShellExecute(0, nil, PChar(LURL), nil, nil, SW_SHOWNOACTIVATE);
|
|
end;
|
|
|
|
procedure TForm1.ButtonStartClick(Sender: TObject);
|
|
begin
|
|
StartServer;
|
|
end;
|
|
|
|
procedure TForm1.ButtonStopClick(Sender: TObject);
|
|
begin
|
|
FServer.Active := False;
|
|
FServer.Bindings.Clear;
|
|
end;
|
|
|
|
procedure TForm1.FormCreate(Sender: TObject);
|
|
begin
|
|
FServer := TIdHTTPWebBrokerBridge.Create(Self);
|
|
end;
|
|
|
|
procedure TForm1.StartServer;
|
|
begin
|
|
if not FServer.Active then
|
|
begin
|
|
FServer.Bindings.Clear;
|
|
FServer.DefaultPort := StrToInt(EditPort.Text);
|
|
FServer.Active := True;
|
|
end;
|
|
end;
|
|
|
|
end.
|