unit RenderSampleControllerU; interface uses MVCFramework, MVCFramework.Commons, ObjectsMappers; type [MVCPath('/')] TRenderSampleController = class(TMVCController) public [MVCHTTPMethod([httpGet])] [MVCPath('/customers')] [MVCProduces('application/json')] [MVCProduces('text/html')] procedure GetCustomers_AsDataSet(CTX: TWebContext); [MVCHTTPMethod([httpGet])] [MVCPath('/people')] [MVCProduces('application/json')] procedure GetPeople_AsObjectList(CTX: TWebContext); [MVCHTTPMethod([httpGet])] [MVCPath('/customers/($id).html')] [MVCProduces('text/html', 'UTF-8')] procedure GetPerson_AsHTML(CTX: TWebContext); [MVCHTTPMethod([httpGet])] [MVCPath('/customers/($id)')] [MVCProduces('application/json')] procedure GetCustomerByID_AsTObject(CTX: TWebContext); [MVCHTTPMethod([httpGet])] [MVCPath('/files/customers.json')] [MVCProduces('application/json')] procedure GetPersonJSON(CTX: TWebContext); [MVCHTTPMethod([httpGet])] [MVCPath('/files/customers.txt')] [MVCProduces('text/plain')] procedure GetPerson_AsText(CTX: TWebContext); [MVCHTTPMethod([httpGet])] [MVCPath('/files/customers.png')] [MVCProduces('image/png')] procedure GetPersonPhoto(CTX: TWebContext); end; implementation uses System.SysUtils, BusinessObjectsU, Data.DBXJSON, WebModuleU, Generics.Collections; { TRoutingSampleController } procedure TRenderSampleController.GetCustomerByID_AsTObject(CTX: TWebContext); var Cust: TCustomer; begin if CTX.Request.ParamsAsInteger['id'] = 7 then // just a sample Render(404, 'Customer Not Found') else begin Cust := TCustomer.Create; Cust.Name := 'Daniele Teti Inc.'; Cust.ContactFirst := 'Daniele'; Cust.ContactLast := 'Teti'; Cust.AddressLine1 := 'Rome Street 12'; Cust.AddressLine2 := '00100'; Cust.City := 'ROME'; Render(Cust); end; end; procedure TRenderSampleController.GetCustomers_AsDataSet(CTX: TWebContext); var wm: TWebModule1; begin wm := GetCurrentWebModule as TWebModule1; wm.qryCustomers.Open; Render(wm.qryCustomers); end; procedure TRenderSampleController.GetPerson_AsHTML(CTX: TWebContext); begin ResponseStream. Append('