You are not logged in.
Pages: 1
Hi,
Is it possible to create instances of the TSQLHttpServer without having to enter TSQLRestServer instance?
I would like in one place the code to create a HTTP server and in other places (controlled by the configuration) add a REST servers.
TssHTTPServer = class(TSQLHttpServer)
public
constructor Create(aHTTPPort: Integer);
end;
constructor TssHTTPServer.Create(aHTTPPort: Integer);
begin
inherited Create(aHTTPPort.ToString, [], '+', useHttpApi, 8); // [] <----- I want to create HTTP server without SQLRestServers
end;
var
httpserver : TssHTTPServer;
begin
httpserver := TssHTTPServer.Create(808);
SomeRestServer := GetServerFromRepo;
httpserver.AddServer(SomeRestServer);
At this moment the order is reversed, I must first have a REST server and then create HTTP server :-(
best regards
Offline
I know. But I need create TSQLHttpServer WITHOUT TSQLRestServer(s) parameter in constructor (mORMmot forcing me to do this).
You did not understand me, my english is crooked, sorry :-)
When I execute this line:
server := TSQLHttpServer.Create('808', [], '+', useHttpApi, 8);
I get exception from TSQLHttpServer constructor:
if ErrMsg<>'' then
raise EModelException.CreateUTF8('%.Create(% ): %',[self,ServersRoot,ErrMsg]);
where ErrMsg is 'No TSQLRestServer'
And I need to create a HTTP server without TSQLRestServer (rest server I will add later).
When I modify TSQLHttpServer constructor (wrong, I know, but temporary, for test only):
constructor TSQLHttpServer.Create(const aPort: AnsiString;
const aServers: array of TSQLRestServer; const aDomainName: AnsiString;
aHttpServerKind: TSQLHttpServerOptions; ServerThreadPoolCount: Integer;
aHttpServerSecurity: TSQLHttpServerSecurity; const aAdditionalURL: AnsiString;
const aQueueName: SynUnicode);
var i,j: integer;
ServersRoot: RawUTF8;
ErrMsg: RawUTF8;
begin
[...]
if high(aServers)<0 then
ErrMsg := 'No TSQLRestServer' else
for i := 0 to high(aServers) do
if (aServers[i]=nil) or (aServers[i].Model=nil) then
ErrMsg := 'Invalid TSQLRestServer';
if ErrMsg='' then
for i := 0 to high(aServers) do
with aServers[i].Model do begin
ServersRoot := ServersRoot+' '+Root;
for j := i+1 to high(aServers) do
if aServers[j].Model.URIMatch(Root) then
ErrMsg:= FormatUTF8('Duplicated Root URI: % and %',[Root,aServers[j].Model.Root]);
end;
ErrMsg := ''; <<<----- my modification, to miss exception
if ErrMsg<>'' then
raise EModelException.CreateUTF8('%.Create(% ): %',[self,ServersRoot,ErrMsg]);
then everything works fine, as I expected.
Offline
And?
How create TSQLHTTPServer with empty "aServers" parameter in constructor?
I need it.
Offline
I've allowed TSQLHttpServer.Create() to run without any associated TSQLRestServer.
See http://synopse.info/fossil/info/8572163c1b
Thanks for the input.
Offline
Big thx Arnaud! :-)
Offline
Pages: 1