#1 2014-09-19 14:49:01

edismo
Member
From: Brazil
Registered: 2013-10-04
Posts: 34

THttpApiServer and TSQLRestServerFullMemory

Hello ab,

I'm trying to integrate AngularJs and mORMot.
for development use the "grunt serves" to the single page app and it consumes one TSQLRestServerFullMemory server, it is working ok.

But to deploy THttpApiServer need to use a server as in example 09 - HttpApi web server. And I'm not understanding how this works.

Must have the same executable using THttpApiServer TSQLRestServerFullMemory?

Is this possible?
I did not understand the architecture?

thanks for listening

Offline

#2 2014-09-19 15:30:12

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,272
Website

Re: THttpApiServer and TSQLRestServerFullMemory

Take a look at mORMotHTTPServer.pas and the corresponding documentation in the SAD 1.18 pdf - see paragraph "Network and Internet access via HTTP" for instance.

You can have several TSQLRestServer* instances in the same TSQLHttpServer.
This is the TSQLHttpServer instance which will its own THttpApiServer instance manage one or several TSQLRestServer* instances.

To server static file, the easiest is to define a method based service in your TSQLRestServerFullMemory, and return file directly:

procedure TServiceServer.Files(Ctxt: TSQLRestServerURIContext);
var FN: TFileName;
begin
  FN := Ctxt.ResourceFileName;
  if FN='' then
    Ctxt.Redirect('Files/index.html') else
    Ctxt.ReturnFile(fPath+FN,true);
//  writeln(FindIniNameValue(pointer(Ctxt.Call.InHead),'REMOTEIP: '),' ',
//    Ctxt.Call^.Method,' ',Ctxt.URIWithoutSignature,' ',Ctxt.Call^.OutStatus);
end;

This will let static content be served in localhost:888/root/Files URI (if your model has "root" as root name).

Offline

#3 2014-09-19 16:26:31

edismo
Member
From: Brazil
Registered: 2013-10-04
Posts: 34

Re: THttpApiServer and TSQLRestServerFullMemory

Thanks AB,

I'll try it.

Offline

#4 2014-09-22 16:50:16

edismo
Member
From: Brazil
Registered: 2013-10-04
Posts: 34

Re: THttpApiServer and TSQLRestServerFullMemory

Hi again AB,

Similar of sample 26 - RESTful ORM with Blob method?

I do not understand, how or who will call the Files method.

Could you explain further or build a simple example with index.html?

Thank you for your attention

Offline

#5 2014-09-23 09:10:13

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,272
Website

Re: THttpApiServer and TSQLRestServerFullMemory

This is a method-based service.
Routing will be automatic, from the method name.
From the above code, TServiceServer.Files() will let static content be served in localhost:888/root/Files URI.

888 is the HTTP server port.
root is the Model "root" parameter".
Files is the method name.

Offline

#6 2014-09-23 16:39:59

edismo
Member
From: Brazil
Registered: 2013-10-04
Posts: 34

Re: THttpApiServer and TSQLRestServerFullMemory

Hello AB,

Thank you.

"localhost:888/root/Files" running my index.html file

It is possible to make "localhost 888/root/" redirects to index.html?

Offline

Board footer

Powered by FluxBB