mirror of
https://github.com/danieleteti/delphimvcframework.git
synced 2024-11-16 08:15:53 +01:00
808e3902d1
Better mobile support for RESTAdapter Better IFDEFing
59 lines
1.2 KiB
ObjectPascal
59 lines
1.2 KiB
ObjectPascal
unit RESTControllerCustomerU;
|
|
|
|
interface
|
|
|
|
uses
|
|
MVCFramework, MVCFramework.Commons, WSHelperCustomersU;
|
|
|
|
type
|
|
|
|
[MVCPath('/')]
|
|
TControllerCustomer = class(TMVCController)
|
|
private
|
|
FWSHelperCustomers: TWSHelperCustomers;
|
|
protected
|
|
procedure OnBeforeAction(Context: TWebContext; const AActionNAme: string;
|
|
var Handled: Boolean); override;
|
|
procedure OnAfterAction(Context: TWebContext;
|
|
const AActionNAme: string); override;
|
|
|
|
public
|
|
[MVCPath('/customers')]
|
|
[MVCHTTPMethod([httpGET])]
|
|
procedure GetCustomers(ctx: TWebContext);
|
|
|
|
[MVCPath('/')]
|
|
[MVCHTTPMethod([httpGET])]
|
|
procedure Index(ctx: TWebContext);
|
|
|
|
end;
|
|
|
|
implementation
|
|
|
|
uses
|
|
System.SysUtils, BOCustomersU;
|
|
|
|
procedure TControllerCustomer.OnBeforeAction(Context: TWebContext;
|
|
const AActionNAme: string; var Handled: Boolean);
|
|
begin
|
|
FWSHelperCustomers := TWSHelperCustomers.Create;
|
|
end;
|
|
|
|
procedure TControllerCustomer.Index(ctx: TWebContext);
|
|
begin
|
|
Redirect('/index.html');
|
|
end;
|
|
|
|
procedure TControllerCustomer.OnAfterAction(Context: TWebContext;
|
|
const AActionNAme: string);
|
|
begin
|
|
FreeAndNil(FWSHelperCustomers);
|
|
end;
|
|
|
|
procedure TControllerCustomer.GetCustomers(ctx: TWebContext);
|
|
begin
|
|
Render<TCustomer>(FWSHelperCustomers.GetCustomers);
|
|
end;
|
|
|
|
end.
|