mirror of
https://github.com/danieleteti/delphimvcframework.git
synced 2024-11-16 00:05:53 +01:00
25177d957f
Submodules update, samples refactoring, build improvements.
62 lines
1.3 KiB
ObjectPascal
62 lines
1.3 KiB
ObjectPascal
unit MVCFramework.Tests.WebModule1;
|
|
|
|
interface
|
|
|
|
uses
|
|
System.SysUtils,
|
|
System.Classes,
|
|
Web.HTTPApp,
|
|
MVCFramework,
|
|
System.Generics.Collections;
|
|
|
|
type
|
|
|
|
TTestWebModule1 = class(TWebModule)
|
|
procedure WebModuleCreate(Sender: TObject);
|
|
procedure WebModuleDestroy(Sender: TObject);
|
|
private
|
|
FMVCEngine: TMVCEngine;
|
|
public
|
|
{ Public declarations }
|
|
end;
|
|
|
|
var
|
|
TestWebModuleClass: TComponentClass = TTestWebModule1;
|
|
|
|
implementation
|
|
|
|
uses
|
|
MVCFramework.Tests.RESTClient,
|
|
MVCFramework.Middleware.Authentication,
|
|
MVCFramework.Tests.AppController,
|
|
MVCFramework.Server,
|
|
MVCFramework.Server.Impl;
|
|
|
|
{$R *.dfm}
|
|
|
|
procedure TTestWebModule1.WebModuleCreate(Sender: TObject);
|
|
begin
|
|
FMVCEngine := TMVCEngine.Create(Self);
|
|
|
|
// Add Controller
|
|
FMVCEngine.AddController(TAppController);
|
|
|
|
FMVCEngine.AddMiddleware(TMVCBasicAuthenticationMiddleware.Create(
|
|
TMVCDefaultAuthenticationHandler.New
|
|
.SetOnAuthentication(
|
|
procedure(const AUserName, APassword: string;
|
|
AUserRoles: TList<string>; var IsValid: Boolean; const ASessionData: TDictionary<String, String>)
|
|
begin
|
|
IsValid := AUserName.Equals('dmvc') and APassword.Equals('123');
|
|
end
|
|
)
|
|
));
|
|
end;
|
|
|
|
procedure TTestWebModule1.WebModuleDestroy(Sender: TObject);
|
|
begin
|
|
FMVCEngine.Free;
|
|
end;
|
|
|
|
end.
|