I'm using the XData Demos folder application, specifically the MultiTenantByHeader project, the idea is to use it as a basis for a project where the server has several folders with Firebird Databases, the client application will inform via Header the location of the database in the server. Once the server receives the request, from reading the header it would create or return a connection within a pool to access the data.
I would also like the same dynamic above to obtain the connection to be used also with RemoteDB.
Given the scenario above, here are my doubts:
1 - The correct way to configure a client application so that when a query in xdataset is executed it sends in the header the location of the database would be something like the example below:
RemoteDBDatabase1.OnRequestSending: = RequestSending;
Procedure TfmThreeTierAureliusRemoteDB.RequestSending (Sender: TObject; Req: THttpRequest);
Req.Headers.SetValue ('database-name', 'c: \ database \ data.fdb');
2 - Where would be the appropriate place to execute the AddDatabase method (DBName: string); whereas DBName would come from the Header of the client application, both through XData and RemoteDB.
3 - To use RemoteDB in this scenario I will need an AureliusConnection and optionally an FDConnection, can I simply add these components to the datamodule or will I need to create it dynamically?
4 - If I need to create the FDConnection dynamically does the mode below seem adequate?
function TServerByHeaderModule.CreateConnectionPool (
const DBName: string): IDBConnectionPool;
// Just create your connection pool the way you do normally
// Each connection pool should have its specific connection settings to point
// to the correct database
Connection: = TFDConnection.Create (nil);
Connection.Params.Values ['Database']: = DBName;
Connection.Params.Values ['User_Name']: = 'SYSDBA';
Connection.Params.Values ['Password']: = 'masterkey';
Connection.Params.Values ['Server']: = 'localhost';
Result: = TDBConnectionPool.Create (10,
Result: = TFireDacConnectionAdapter.Create (Connection, False);
// Result: = TSQLiteNativeConnectionAdapter.Create (DBName + '.db');
5 - How would it be to obtain information from the database location that comes in the request header, I can make use of the connection related to it that is in the pool for both xdata and remotedb?