Hi there
Not sure that this question (I try to do it just for education purpose) relies on XData, may be more suitable chapter is Sparkle...
But anyway, I'll try to exaplian wehat I'm looking for.
In XData we have under XDataServer component property DefaultEntitySetPermissions and according to this automatic endpoints will be accordingly wisible in my server.
There good example also how to implement probably same in code:
{
This service contract creates the following endpoints:
GET /customers -- Get all customers
POST /customers -- Create a customer
GET /customers/:id -- Get a specific customer
PUT /customers/:id -- Update a customer
DELETE /customers/:id -- Delete a customer
}
[ServiceContract]
[Route('customers')]
ICustomerService = interface(IInvokable)
['{D2981778-B681-4D4B-B95E-9816B5C7F1D1}']
[HttpPost, Route('')]
procedure CreateCustomer(Customer: TCustomer);
[HttpGet, Route('')]
function GetCustomers: TList<TCustomer>;
[HttpGet, Route('{Id}')]
function GetCustomer(Id: Integer): TCustomer;
[HttpPut, Route('{Id}')]
procedure UpdateCustomer(Id: Integer; Customer: TCustomer);
[HttpDelete, Route('{Id}')]
procedure DeleteCustomer(Id: Integer);
end;
But is it possible somehow to add service contract in code?
More clearly - what if I have 10 + tables with the same structure (id, name fields) and want to add in code / runtime all those table's endpoint (maybe tied to the same implemented functions) so that Swaggger also shows all those separately?
The reason for that - I don't know before hand how much table there are in database...
But any plain registers / lists:
/customers/:id
/automobiles/
/employees/:id
/bids/:id
can be resolved correctly (from right table)..
What I understand so far, I'm able to add any endpoint through TAnonymousServerModule and process responses there....
In case if I not intend to use Aurelius (but result always is some json) probably is there any solution not to hardcode every class / entity but do it in more flexible way.
Thank you in advance.