unit MainControllerU; interface uses MVCFramework, MVCFramework.Commons, MVCFramework.Serializer.Commons; type [MVCPath('/api')] TMyController = class(TMVCController) public [MVCPath] [MVCConsumes(TMVCMediaType.TEXT_HTML)] [MVCHTTPMethod([httpGET])] procedure Index; [MVCPath('/reversedstrings/($Value)')] [MVCHTTPMethod([httpGET])] procedure GetReversedString(const Value: string); protected procedure OnBeforeAction(Context: TWebContext; const AActionName: string; var Handled: Boolean); override; procedure OnAfterAction(Context: TWebContext; const AActionName: string); override; public // Sample CRUD Actions for a "Customer" entity [MVCPath('/customers')] [MVCHTTPMethod([httpGET])] procedure GetCustomers; [MVCPath('/customers/($id)')] [MVCHTTPMethod([httpGET])] procedure GetCustomer(id: Integer); [MVCPath('/customers')] [MVCHTTPMethod([httpPOST])] procedure CreateCustomer; [MVCPath('/customers/($id)')] [MVCHTTPMethod([httpPUT])] procedure UpdateCustomer(id: Integer); [MVCPath('/customers/($id)')] [MVCHTTPMethod([httpDELETE])] procedure DeleteCustomer(id: Integer); end; implementation uses System.SysUtils, MVCFramework.Logger, System.StrUtils; procedure TMyController.Index; begin Redirect('/static'); end; procedure TMyController.GetReversedString(const Value: string); begin Render(System.StrUtils.ReverseString(Value.Trim)); end; procedure TMyController.OnAfterAction(Context: TWebContext; const AActionName: string); begin { Executed after each action } inherited; end; procedure TMyController.OnBeforeAction(Context: TWebContext; const AActionName: string; var Handled: Boolean); begin { Executed before each action if handled is true (or an exception is raised) the actual action will not be called } inherited; end; // Sample CRUD Actions for a "Customer" entity procedure TMyController.GetCustomers; begin // todo: render a list of customers end; procedure TMyController.GetCustomer(id: Integer); begin // todo: render the customer by id end; procedure TMyController.CreateCustomer; begin // todo: create a new customer end; procedure TMyController.UpdateCustomer(id: Integer); begin // todo: update customer by id end; procedure TMyController.DeleteCustomer(id: Integer); begin // todo: delete customer by id end; end.