Skip to content

Commit

Permalink
Initial loading
Browse files Browse the repository at this point in the history
  • Loading branch information
andrea-magni committed Dec 14, 2015
1 parent 1a208dd commit eba3117
Show file tree
Hide file tree
Showing 252 changed files with 36,884 additions and 0 deletions.
23 changes: 23 additions & 0 deletions Demos/Authorization/MARSAuthorization.dpr
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
(*
Copyright 2015, MARS - REST Library
Home: https://github.com/MARS-library
*)
program MARSAuthorization;

uses
Forms,
Server.Forms.Main in 'Server.Forms.Main.pas' {MainForm},
Server.Resources in 'Server.Resources.pas';

{$R *.res}

begin
ReportMemoryLeaksOnShutdown := False;

Application.Initialize;
Application.MainFormOnTaskbar := True;
Application.CreateForm(TMainForm, MainForm);
Application.Run;
end.
112 changes: 112 additions & 0 deletions Demos/Authorization/MARSAuthorization.dproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
 <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectGuid>{4C063F0F-2379-4498-AF43-A655904D3431}</ProjectGuid>
<MainSource>MARSAuthorization.dpr</MainSource>
<Base>True</Base>
<Config Condition="'$(Config)'==''">Debug</Config>
<Platform>Win32</Platform>
<AppType>Application</AppType>
<FrameworkType>VCL</FrameworkType>
<DCC_DCCCompiler>DCC32</DCC_DCCCompiler>
<ProjectVersion>12.3</ProjectVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Config)'=='Base' or '$(Base)'!=''">
<Base>true</Base>
</PropertyGroup>
<PropertyGroup Condition="'$(Config)'=='Release' or '$(Cfg_1)'!=''">
<Cfg_1>true</Cfg_1>
<CfgParent>Base</CfgParent>
<Base>true</Base>
</PropertyGroup>
<PropertyGroup Condition="'$(Config)'=='Debug' or '$(Cfg_2)'!=''">
<Cfg_2>true</Cfg_2>
<CfgParent>Base</CfgParent>
<Base>true</Base>
</PropertyGroup>
<PropertyGroup Condition="'$(Base)'!=''">
<DCC_NameSpace>Web</DCC_NameSpace>
<DCC_E>false</DCC_E>
<DCC_ImageBase>00400000</DCC_ImageBase>
<DCC_UnitAlias>WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE;WinTypes=Windows;WinProcs=Windows;$(DCC_UnitAlias)</DCC_UnitAlias>
<DCC_F>false</DCC_F>
<DCC_S>false</DCC_S>
<DCC_N>false</DCC_N>
<DCC_K>false</DCC_K>
</PropertyGroup>
<PropertyGroup Condition="'$(Cfg_1)'!=''">
<DCC_LocalDebugSymbols>false</DCC_LocalDebugSymbols>
<DCC_Define>RELEASE;$(DCC_Define)</DCC_Define>
<DCC_SymbolReferenceInfo>0</DCC_SymbolReferenceInfo>
<DCC_DebugInformation>false</DCC_DebugInformation>
</PropertyGroup>
<PropertyGroup Condition="'$(Cfg_2)'!=''">
<DCC_Define>DEBUG;$(DCC_Define)</DCC_Define>
<DCC_Optimize>false</DCC_Optimize>
<DCC_GenerateStackFrames>true</DCC_GenerateStackFrames>
</PropertyGroup>
<ItemGroup>
<DelphiCompile Include="MARSAuthorization.dpr">
<MainSource>MainSource</MainSource>
</DelphiCompile>
<DCCReference Include="Server.Forms.Main.pas">
<Form>MainForm</Form>
</DCCReference>
<DCCReference Include="Server.Resources.pas"/>
<DCCReference Include="Tests\Tests.Authorization.pas"/>
<BuildConfiguration Include="Debug">
<Key>Cfg_2</Key>
<CfgParent>Base</CfgParent>
</BuildConfiguration>
<BuildConfiguration Include="Base">
<Key>Base</Key>
</BuildConfiguration>
<BuildConfiguration Include="Release">
<Key>Cfg_1</Key>
<CfgParent>Base</CfgParent>
</BuildConfiguration>
</ItemGroup>
<Import Condition="Exists('$(BDS)\Bin\CodeGear.Delphi.Targets')" Project="$(BDS)\Bin\CodeGear.Delphi.Targets"/>
<Import Condition="Exists('$(APPDATA)\Embarcadero\$(BDSAPPDATABASEDIR)\$(PRODUCTVERSION)\UserTools.proj')" Project="$(APPDATA)\Embarcadero\$(BDSAPPDATABASEDIR)\$(PRODUCTVERSION)\UserTools.proj"/>
<ProjectExtensions>
<Borland.Personality>Delphi.Personality.12</Borland.Personality>
<Borland.ProjectType>VCLApplication</Borland.ProjectType>
<BorlandProject>
<Delphi.Personality>
<Source>
<Source Name="MainSource">MARSAuthorization.dpr</Source>
</Source>
<VersionInfo>
<VersionInfo Name="IncludeVerInfo">True</VersionInfo>
<VersionInfo Name="AutoIncBuild">False</VersionInfo>
<VersionInfo Name="MajorVer">1</VersionInfo>
<VersionInfo Name="MinorVer">0</VersionInfo>
<VersionInfo Name="Release">0</VersionInfo>
<VersionInfo Name="Build">0</VersionInfo>
<VersionInfo Name="Debug">False</VersionInfo>
<VersionInfo Name="PreRelease">False</VersionInfo>
<VersionInfo Name="Special">False</VersionInfo>
<VersionInfo Name="Private">False</VersionInfo>
<VersionInfo Name="DLL">False</VersionInfo>
<VersionInfo Name="Locale">1033</VersionInfo>
<VersionInfo Name="CodePage">1252</VersionInfo>
</VersionInfo>
<VersionInfoKeys>
<VersionInfoKeys Name="CompanyName"/>
<VersionInfoKeys Name="FileDescription"/>
<VersionInfoKeys Name="FileVersion">1.0.0.0</VersionInfoKeys>
<VersionInfoKeys Name="InternalName"/>
<VersionInfoKeys Name="LegalCopyright"/>
<VersionInfoKeys Name="LegalTrademarks"/>
<VersionInfoKeys Name="OriginalFilename"/>
<VersionInfoKeys Name="ProductName"/>
<VersionInfoKeys Name="ProductVersion">1.0.0.0</VersionInfoKeys>
<VersionInfoKeys Name="Comments"/>
</VersionInfoKeys>
</Delphi.Personality>
<Platforms>
<Platform value="Win32">True</Platform>
</Platforms>
</BorlandProject>
<ProjectFileVersion>12</ProjectFileVersion>
</ProjectExtensions>
</Project>
Binary file added Demos/Authorization/MARSAuthorization.res
Binary file not shown.
20 changes: 20 additions & 0 deletions Demos/Authorization/Server.Data.Main.dfm
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
object DataMain: TDataMain
OldCreateOrder = False
Height = 287
Width = 391
object DatabaseConnection: TFDConnection
Params.Strings = (
'ConnectionDef=Firebird_Employee_Pooled')
Connected = True
Left = 88
Top = 32
end
object EmployeeQuery: TFDQuery
Active = True
Connection = DatabaseConnection
SQL.Strings = (
'select * from EMPLOYEE')
Left = 88
Top = 112
end
end
36 changes: 36 additions & 0 deletions Demos/Authorization/Server.Data.Main.pas
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
(*
Copyright 2015, MARS - REST Library
Home: https://github.com/MARS-library
*)
unit Server.Data.Main;

interface

uses
System.SysUtils, System.Classes, FireDAC.Stan.Intf, FireDAC.Stan.Option,
FireDAC.Stan.Error, FireDAC.UI.Intf, FireDAC.Phys.Intf, FireDAC.Stan.Def,
FireDAC.Stan.Pool, FireDAC.Stan.Async, FireDAC.Phys, FireDAC.Phys.FB,
FireDAC.Phys.FBDef, Data.DB, FireDAC.Comp.Client, FireDAC.Stan.Param,
FireDAC.DatS, FireDAC.DApt.Intf, FireDAC.DApt, FireDAC.Comp.DataSet

, MARS.Core.Attributes;

type
TDataMain = class(TDataModule)
DatabaseConnection: TFDConnection;
[Rest]
EmployeeQuery: TFDQuery;
private
{ Private declarations }
public
end;

implementation

{%CLASSGROUP 'Vcl.Controls.TControl'}

{$R *.dfm}

end.
72 changes: 72 additions & 0 deletions Demos/Authorization/Server.Forms.Main.dfm
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
object MainForm: TMainForm
Left = 0
Top = 0
Caption = 'MARS Authorization'
ClientHeight = 289
ClientWidth = 554
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
OnClose = FormClose
OnCreate = FormCreate
PixelsPerInch = 96
TextHeight = 13
object TopPanel: TPanel
Left = 0
Top = 0
Width = 554
Height = 73
Align = alTop
BevelOuter = bvNone
TabOrder = 0
object Label1: TLabel
Left = 28
Top = 17
Width = 63
Height = 13
Caption = 'Port number:'
end
object StartButton: TButton
Left = 16
Top = 41
Width = 75
Height = 25
Action = StartServerAction
TabOrder = 0
end
object StopButton: TButton
Left = 104
Top = 41
Width = 75
Height = 25
Action = StopServerAction
TabOrder = 1
end
object PortNumberEdit: TEdit
Left = 97
Top = 14
Width = 82
Height = 21
TabOrder = 2
Text = '8080'
end
end
object MainActionList: TActionList
Left = 104
Top = 96
object StartServerAction: TAction
Caption = 'Start Server'
OnExecute = StartServerActionExecute
OnUpdate = StartServerActionUpdate
end
object StopServerAction: TAction
Caption = 'Stop Server'
OnExecute = StopServerActionExecute
OnUpdate = StopServerActionUpdate
end
end
end
124 changes: 124 additions & 0 deletions Demos/Authorization/Server.Forms.Main.pas
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
(*
Copyright 2015, MARS - REST Library
Home: https://github.com/MARS-library
*)
unit Server.Forms.Main;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics,
Controls, Forms, Dialogs, ActnList, StdCtrls, ExtCtrls

, Diagnostics
, IdContext

, MARS.Core.Engine
, MARS.http.Server.Indy


, MARS.Core.Application, System.Actions
;

type
TMainForm = class(TForm)
TopPanel: TPanel;
StartButton: TButton;
StopButton: TButton;
MainActionList: TActionList;
StartServerAction: TAction;
StopServerAction: TAction;
PortNumberEdit: TEdit;
Label1: TLabel;
procedure StartServerActionExecute(Sender: TObject);
procedure StartServerActionUpdate(Sender: TObject);
procedure StopServerActionExecute(Sender: TObject);
procedure StopServerActionUpdate(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
FServer: TMARShttpServerIndy;
FEngine: TMARSEngine;
public
end;

var
MainForm: TMainForm;

implementation

{$R *.dfm}

uses
MARS.Core.MessageBodyWriter
, MARS.Core.MessageBodyWriters
;

procedure TMainForm.FormClose(Sender: TObject; var Action: TCloseAction);
begin
StopServerAction.Execute;
end;

procedure TMainForm.FormCreate(Sender: TObject);
begin
StartServerAction.Execute;
end;

procedure TMainForm.StartServerActionExecute(Sender: TObject);
begin
FEngine := TMARSEngine.Create;

// Engine configuration
FEngine.Port := StrToIntDef(PortNumberEdit.Text, 8080);
FEngine.ThreadPoolSize := 75;
FEngine.Name := 'MARS HelloWorld';
FEngine.BasePath := '/rest';

FEngine.AddApplication(
'Default'
, '/default'
, ['Server.Resources.TFirstResource',
'Server.Resources.TTokenResource'
]
);

// FEngine.AddApplication(
// 'Diagnostics'
// , '/diagnostics'
// , [ 'MARS.Diagnostics.Resources.TDiagnosticsResource'
// ,'MARS.Diagnostics.Resources.TResourcesResource'
// ]
// ).System := True;
// TMARSDiagnosticsManager.FEngine := FEngine;
// TMARSDiagnosticsManager.Instance; // force instance creation

// Create http server
FServer := TMARShttpServerIndy.Create(FEngine);

if not FServer.Active then
FServer.Active := True;
end;

procedure TMainForm.StartServerActionUpdate(Sender: TObject);
begin
StartServerAction.Enabled := (FServer = nil) or (FServer.Active = False);
end;

procedure TMainForm.StopServerActionExecute(Sender: TObject);
begin
FServer.Active := False;
FServer.Free;
FServer := nil;

FEngine.Free;
FEngine := nil;
end;

procedure TMainForm.StopServerActionUpdate(Sender: TObject);
begin
StopServerAction.Enabled := Assigned(FServer) and (FServer.Active = True);
end;

end.
Loading

0 comments on commit eba3117

Please sign in to comment.