XData Server without Aurelius/Database 2

I'd obviously closed the last post a bit early.

I'm trying to do this all in code and am obviously missing something. My StartServer procedure is something like

procedure StartServer;
var
  Module : TXDataServer;
begin
  if Assigned(SparkleServer) then
     Exit;

  SparkleServer := THttpSysServer.Create;

  Module := TXDataServer.Create(Nil);
  Module.BaseUrl := SystemSettings.ListenBaseURI + '/auth';
  Module.ModelName := AUTH_MODEL;
  Module.SwaggerOptions.Enabled := True;
  Module.MiddlewareList.Add(TSparkleCorsMiddleware.Create(Nil));

  SparkleServer.AddModule(Module);

  SparkleServer.Start;
end;

This fails on SparkleServer.AddModule(Module); Obviously I ned the TXDataServerModule which is created, but can't quite work out how to fit it all together.

Any pointers, thanks

That's a different question anyway. And TXDataServer component should be associated with TSparkleHttpSysDispatcher. You are mixing RAD, design-time components with the more simples classes they wrap. So either use one approach or the other.

Also, if you are creating everything from code, why using the RAD components? Just use TXDataServerModule instead of TXDataServer.

1 Like

Ok, I'll do that - just seemed that you can use a modelname rather than an Aurelius Model with the TXDataServer. Thanks

1 Like