You are not logged in.
Pages: 1
Hello
I wanted to do a simple test without using any ORM instance, but I'm getting an "Access Violation" error. What am I missing?
mormot.rest.core.pas
procedure TRest.OnBeginCurrentThread(Sender: TThread);
begin
fOrmInstance.BeginCurrentThread(Sender); <<< fOrmInstance has not been created; Access Violation
end;
...
type
TSampleServer = class(TRestServer)
published
procedure test(Ctxt: TRestServerUriContext);
end;
...
FApiServer:TSampleServer;
FHttpServer:TRestHttpServer;
...
procedure TForm1.FormCreate(Sender: TObject);
begin
FApiServer:=TSampleServer.Create('api');
FHttpServer := TRestHttpServer.Create('80', [FApiServer], '+', HTTP_DEFAULT_MODE, 4);
FHttpServer.AccessControlAllowOrigin := '*';
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
FHttpServer.Free;
FApiServer.Free;
end;
procedure TSampleServer.test(Ctxt: TRestServerUriContext);
begin
Ctxt.Returns('{"result":null}');
end;
Offline
Thanks ab :$
I want to get rid of SQL, so I'll use ORM
Offline
I had already realized that I needed to use TRestServerFullMemory after your message. Thanks
Offline
In the future, I would like to make a high-level wrapper server class around all those multiple classes, to make it easier to use.
The framework has so many possibilities, it is likely to be intimidating and confusing.
Offline
First of all, you did a great job. Thanks again.
Like you, I think some structures should be simplified. For those new to mORMot, the learning curve should be rapid. After learning mORMot, I would like to contribute.
//I think these types of regulations you are talking about are;
FHttpServer:TContainerHttpServer; // or TAppHttpServer
FRestApp:TRestHttpApplication; // or TRestHttpService
FRawApp:TRawHttpAppication; // or TRawHttpService
FMvcApp:TMvcHttpApplication; // or TMvcHttpService
FHttpServer.Create('0.0.0.0:80', [FRestApp, FRawApp]);
FRestApp.Root:='/api';
FRestApp.Storage:=TOrmModel;
//FRestApp.Storage:=TMemoryModel;
FRawApp.Root:='/';
FRawApp.StaticsPath:='/statics'
Last edited by nakisen (2024-01-07 22:29:13)
Offline
I have enhanced the documentation about not to use TRestServer:
https://github.com/synopse/mORMot2/commit/a141b409
Offline
Pages: 1