Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program cbserver;
- {$I Synopse.inc}
- uses
- {$I SynDprUses.inc}
- Classes, SysUtils,
- SynCommons, SynLog, mORMot, mORMotHttpServer, mORMotSQLite3, SynSQLite3Static, SynDB;
- type
- { ICBService }
- ICBService = interface(IInvokable)
- ['{2061324A-51C8-48FC-82CC-D21ECC3D16E1}']
- function Test2: RawUTF8;
- end;
- { TCBService }
- TCBService = class(TInjectableObjectRest, ICBService)
- function Test2: RawUTF8;
- end;
- const
- ROOT_NAME = 'root';
- DEFAULT_PORT = '1044';
- var
- aServer: TSQLRestServer;
- aHTTPServer: TSQLHttpServer;
- aModel: TSQLModel;
- { TCBService }
- function TCBService.Test2: RawUTF8;
- begin
- Result := 'sss';
- end;
- begin
- TInterfaceFactory.RegisterInterfaces([TypeInfo(ICBService)]);
- with TSQLLog.Family do begin
- Level := LOG_VERBOSE;
- EchoToConsole := LOG_VERBOSE; // log all events to the console
- end;
- aModel := TSQLModel.Create([], ROOT_NAME);
- try
- aServer := TSQLRestServerDB.Create(aModel, 'cbs.db3', false);
- try
- aServer.CreateMissingTables;
- aServer.ServiceDefine(TCBService, [ICBService], sicShared);
- aHTTPServer := TSQLHttpServer.Create(AnsiString(DEFAULT_PORT), [aServer], '+', useHttpApiRegisteringURI);
- try
- writeln(#10'Background server is running.'#10);
- writeln('Press [Enter] to close the server.'#10);
- readln;
- finally
- aHTTPServer.Free;
- end;
- sleep(100);
- finally
- aServer.Free;
- end;
- finally
- aModel.Free;
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment