I would need to carry some custom informations retrieved when crreating server / modules (from ini files or database) so they are available for each request (ie in TXDataOperationContext.Current)
Is there a way to do so ?
I would need to carry some custom informations retrieved when crreating server / modules (from ini files or database) so they are available for each request (ie in TXDataOperationContext.Current)
You should create your own data structure. One thing you can do is use a similar approach as described here:
threadvar
MyContext: TMyContext;
procedure TDataModule1.MiddlewareRequest(Sender: TObject;Context: THttpServerContext; Next: THttpServerProc);
begin
MyContext := TMyContext.Create;
try
Next(C);
finally
MyContext.Free;
end;
end;
Maybe I'm getting it wrong but with your suggestion TMyContext would be only available in middleware scope.
Just declare the MyContext threadvar in a common unit used by both the middleware and your module code. That is not a problem.
But in this case the config (conf1,conf2...) would be read for each request which I dont want. I need the config to be read once when server starts