2013-10-30 01:09:09 +01:00
|
|
|
unit TestControllersU;
|
|
|
|
|
|
|
|
interface
|
|
|
|
|
|
|
|
uses MVCFramework.Commons,
|
|
|
|
System.Classes,
|
|
|
|
Web.HTTPApp,
|
|
|
|
MVCFramework;
|
|
|
|
|
|
|
|
type
|
|
|
|
|
|
|
|
[MVCPath('/')]
|
|
|
|
TSimpleController = class(TMVCController)
|
|
|
|
private
|
|
|
|
FCalledActions: TStringList;
|
2015-02-16 14:25:09 +01:00
|
|
|
procedure AddCall(ActionName: string);
|
2013-10-30 01:09:09 +01:00
|
|
|
|
|
|
|
protected
|
|
|
|
procedure MVCControllerAfterCreate; override;
|
|
|
|
procedure MVCControllerBeforeDestroy; override;
|
|
|
|
|
|
|
|
public
|
|
|
|
[MVCPath('/')]
|
|
|
|
procedure Index(Context: TWebContext);
|
2014-06-27 15:30:39 +02:00
|
|
|
|
|
|
|
[MVCPath('/orders')]
|
|
|
|
[MVCProduces('application/json')]
|
|
|
|
procedure OrdersProduceJSON(Context: TWebContext);
|
|
|
|
|
2013-10-30 01:09:09 +01:00
|
|
|
[MVCPath('/orders')]
|
|
|
|
procedure Orders(Context: TWebContext);
|
|
|
|
|
|
|
|
[MVCHTTPMethod([httpGET])]
|
|
|
|
[MVCPath('/orders/($ordernumber)')]
|
|
|
|
procedure OrderNumber(Context: TWebContext);
|
|
|
|
|
|
|
|
[MVCHTTPMethod([httpPOST, httpPUT])]
|
|
|
|
[MVCPath('/orders/($ordernumber)')]
|
|
|
|
procedure UpdateOrderNumber(Context: TWebContext);
|
|
|
|
|
2014-03-24 17:37:08 +01:00
|
|
|
[MVCHTTPMethod([httpPATCH])]
|
|
|
|
[MVCPath('/orders/($ordernumber)')]
|
|
|
|
procedure PatchOrder(Context: TWebContext);
|
|
|
|
|
2013-10-30 01:09:09 +01:00
|
|
|
property CalledActions: TStringList read FCalledActions; // only for tests
|
|
|
|
end;
|
|
|
|
|
2013-11-19 18:17:06 +01:00
|
|
|
TNotSoSimpleController = class(TMVCController)
|
|
|
|
public
|
|
|
|
procedure Method1(CTX: TWebContext);
|
|
|
|
end;
|
|
|
|
|
2013-10-30 01:09:09 +01:00
|
|
|
implementation
|
|
|
|
|
|
|
|
{ TSimpleController }
|
|
|
|
|
2015-02-16 14:25:09 +01:00
|
|
|
procedure TSimpleController.AddCall(ActionName: string);
|
2013-10-30 01:09:09 +01:00
|
|
|
begin
|
|
|
|
FCalledActions.Add(ActionName);
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TSimpleController.Index(Context: TWebContext);
|
|
|
|
begin
|
|
|
|
AddCall('Index');
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TSimpleController.MVCControllerAfterCreate;
|
|
|
|
begin
|
|
|
|
inherited;
|
|
|
|
FCalledActions := TStringList.Create;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TSimpleController.MVCControllerBeforeDestroy;
|
|
|
|
begin
|
|
|
|
FCalledActions.Free;
|
|
|
|
inherited;
|
|
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TSimpleController.Orders(Context: TWebContext);
|
|
|
|
begin
|
|
|
|
|
|
|
|
end;
|
|
|
|
|
2014-06-27 15:30:39 +02:00
|
|
|
procedure TSimpleController.OrdersProduceJSON(Context: TWebContext);
|
|
|
|
begin
|
|
|
|
|
|
|
|
end;
|
|
|
|
|
2014-03-24 17:37:08 +01:00
|
|
|
procedure TSimpleController.PatchOrder(Context: TWebContext);
|
|
|
|
begin
|
|
|
|
|
|
|
|
end;
|
|
|
|
|
2013-10-30 01:09:09 +01:00
|
|
|
procedure TSimpleController.UpdateOrderNumber(Context: TWebContext);
|
|
|
|
begin
|
|
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TSimpleController.OrderNumber(Context: TWebContext);
|
|
|
|
begin
|
|
|
|
|
|
|
|
end;
|
|
|
|
|
2013-11-19 18:17:06 +01:00
|
|
|
{ TNotSoSimpleController }
|
|
|
|
|
|
|
|
procedure TNotSoSimpleController.Method1(CTX: TWebContext);
|
|
|
|
begin
|
|
|
|
|
|
|
|
end;
|
|
|
|
|
2013-10-30 01:09:09 +01:00
|
|
|
end.
|