2015-12-22 12:29:25 +01:00
|
|
|
unit MVCFramework.Tests.WebModule;
|
2015-06-15 18:57:46 +02:00
|
|
|
|
|
|
|
interface
|
|
|
|
|
|
|
|
uses
|
|
|
|
System.SysUtils,
|
|
|
|
System.Classes,
|
|
|
|
Web.HTTPApp,
|
|
|
|
MVCFramework;
|
|
|
|
|
|
|
|
type
|
|
|
|
|
|
|
|
TTestWebModule = class(TWebModule)
|
|
|
|
procedure WebModuleCreate(Sender: TObject);
|
|
|
|
procedure WebModuleDestroy(Sender: TObject);
|
|
|
|
private
|
|
|
|
FMVCEngine: TMVCEngine;
|
|
|
|
public
|
|
|
|
{ Public declarations }
|
|
|
|
end;
|
|
|
|
|
|
|
|
var
|
|
|
|
TestWebModuleClass: TComponentClass = TTestWebModule;
|
|
|
|
|
|
|
|
implementation
|
|
|
|
|
|
|
|
uses
|
2015-12-22 12:29:25 +01:00
|
|
|
MVCFramework.Tests.StandaloneServer,
|
2015-06-15 22:51:36 +02:00
|
|
|
MVCFramework.Middleware.Authentication,
|
|
|
|
MVCFramework.Server;
|
2015-06-15 18:57:46 +02:00
|
|
|
|
|
|
|
{$R *.dfm}
|
|
|
|
|
|
|
|
procedure TTestWebModule.WebModuleCreate(Sender: TObject);
|
2015-06-15 22:51:36 +02:00
|
|
|
var
|
|
|
|
vServer: IMVCServer;
|
2015-06-15 18:57:46 +02:00
|
|
|
begin
|
|
|
|
FMVCEngine := TMVCEngine.Create(Self);
|
2015-06-15 22:51:36 +02:00
|
|
|
|
2016-02-29 13:48:36 +01:00
|
|
|
// Add With Delegate Constructor Controller
|
|
|
|
FMVCEngine.AddController(TTestAppController,
|
|
|
|
function: TMVCController
|
|
|
|
begin
|
|
|
|
Result := TTestAppController.Create;
|
|
|
|
end
|
|
|
|
);
|
2015-06-15 22:51:36 +02:00
|
|
|
|
|
|
|
// Add Security Middleware
|
|
|
|
vServer := ServerContainer.FindServerByName('ServerTemp');
|
|
|
|
if (vServer <> nil) and (vServer.Info.Security <> nil) then
|
|
|
|
FMVCEngine.AddMiddleware(TMVCBasicAuthenticationMiddleware.Create(vServer.Info.Security));
|
2015-06-15 18:57:46 +02:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TTestWebModule.WebModuleDestroy(Sender: TObject);
|
|
|
|
begin
|
|
|
|
FreeAndNil(FMVCEngine);
|
|
|
|
end;
|
|
|
|
|
|
|
|
end.
|