And also question about CreateServicePool realization. Below 2 variants,
both are works, but which should be used?
function CreateServicePool1: IDBConnectionPool;
begin
Result := TDBConnectionPool.Create(PoolSize, TDBConnectionFactory.Create(
function: IDBConnection
begin
Result := TSQLiteNativeConnectionAdapter.Create(':memory:');
end));
end;
function CreateServicePool: IDBConnectionPool;
begin
Result := TDBConnectionPool.Create(PoolSize, TDBConnectionFactory.Create(
function: IDBConnection
var
Connection: TAureliusConnection;
begin
Connection := TAureliusConnection.Create(nil);
Connection.Params.Values['Database'] := ':memory:';
Connection.Params.Values['DriverID'] := 'SQLite';
Result := Connection.CreateConnection;
Connection.Free;
end));
end;
You can simply allow anonymous access in the middleware and then prevent accessing the protected API. Or, use a different Sparkle module for the protected part of the API and another one for the API that allows anonymous access.
Both approaches are fine. But personally I'd prefer the first one as TAureliusConnection is actually just a wrapper around the first one.
Also note that specifically for SQLite in-memory databases, you should always have a pool of size 1, since each new in-memory SQLite database you create will be a different one.