delphimvcframework/samples/soaprest/webservices/rest/RESTControllerCustomerU.pas
Tristan Marlow 80a0bc8f8c MVCFramework option for unhandled actions
ObjectMappers DataSetToObject support boolean types
Sample\SoapRest Example application server providing both SOAP and REST webservices
2015-12-02 11:14:15 +08:00

50 lines
1.0 KiB
ObjectPascal

unit RESTControllerCustomerU;
interface
uses
MVCFramework, WSHelperCustomersU;
type
[MVCPath('/customers')]
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]
[MVCHTTPMethod([httpGET])]
procedure GetCustomers(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.OnAfterAction(Context: TWebContext;
const AActionNAme: string);
begin
FreeAndNil(FWSHelperCustomers);
end;
procedure TControllerCustomer.GetCustomers(ctx: TWebContext);
begin
Render<TCustomer>(FWSHelperCustomers.GetCustomers);
end;
end.