library DataSnapServerWebBrokerISAPI;
uses
  CodeSiteLogging,
  Winapi.ActiveX,
  System.Win.ComObj,
  Web.WebBroker,
  Web.Win.ISAPIApp,
  Web.Win.ISAPIThreadPool,
  Data.DBXCommon,
  Datasnap.DSService,
  ServerMethodsUnit1 in 'ServerMethodsUnit1.pas' {MyServerMethods: TDSServerModule},
  WebModuleUnit1 in 'WebModuleUnit1.pas' {WebModule1: TWebModule};

{$R *.res}

exports
  GetExtensionVersion,
  HttpExtensionProc,
  TerminateExtension;

procedure TerminateThreads;
begin
  TDSSessionManager.Instance.Free;
  Data.DBXCommon.TDBXScheduler.Instance.Free;
end;

begin
  CoInitFlags := COINIT_MULTITHREADED;
  Application.Initialize;
  {$IFDEF DEBUG}
  CodeSiteManager.ConnectUsingTcp; // for local services (like IIS)...
  CodeSite.Enabled := CodeSite.Installed;
  CodeSite.Clear;
  CodeSite.Send('DataSnapServerRESTISAPI loaded');
  {$ELSE}
  CodeSite.Enabled := False;
  {$ENDIF}
  Application.WebModuleClass := WebModuleClass;
  TISAPIApplication(Application).OnTerminate := TerminateThreads;
  Application.Run;
end.
