mirror of
https://github.com/danieleteti/delphimvcframework.git
synced 2024-11-16 00:05:53 +01:00
55 lines
1.1 KiB
ObjectPascal
55 lines
1.1 KiB
ObjectPascal
unit MVCFramework.Tests.WebModule;
|
|
|
|
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
|
|
MVCFramework.Tests.StandaloneServer,
|
|
MVCFramework.Middleware.Authentication,
|
|
MVCFramework.Server;
|
|
|
|
{$R *.dfm}
|
|
|
|
procedure TTestWebModule.WebModuleCreate(Sender: TObject);
|
|
var
|
|
vServer: IMVCServer;
|
|
begin
|
|
FMVCEngine := TMVCEngine.Create(Self);
|
|
|
|
// Add Controller
|
|
FMVCEngine.AddController(TTestAppController);
|
|
|
|
// Add Security Middleware
|
|
vServer := ServerContainer.FindServerByName('ServerTemp');
|
|
if (vServer <> nil) and (vServer.Info.Security <> nil) then
|
|
FMVCEngine.AddMiddleware(TMVCBasicAuthenticationMiddleware.Create(vServer.Info.Security));
|
|
end;
|
|
|
|
procedure TTestWebModule.WebModuleDestroy(Sender: TObject);
|
|
begin
|
|
FreeAndNil(FMVCEngine);
|
|
end;
|
|
|
|
end.
|