#1 2017-05-26 11:33:39

NoSaint50
Member
Registered: 2017-05-26
Posts: 4

Rest Server with multiple interfaces

Hello all,

So .. I'm currently at "Install +25 minutes" and, so far, liking what I'm seeing. This looks to be a really good framework.

I found the Third Party folder with George's Rest-tester and am wondering how to go about adding more interfaces to this. I follow what's happening in the RestMethodsInterfaceUnit and RestServerMethodsUnit, so I'm assuming I'd add 2 more units, say TestInterfaceUnit and TestUnit.
The TRestServer.Initialize call in RestServerUnit is where things start getting difficult. Do I need to create a second TSQLModel and TSQLRestServerFullMemory, or just repeat these calls with new constants ROOT_NAME2 and SERVICE_INSTANCE_IMPLEMENTATION" ?? Is this the best way to tackle this if eventually I'd have loads of Interfaces for different areas of an application? Is there an Interface "collection" that could be used?

I don't mind doing all the reading if someone can point me to the right area, or some pseudo code I can play about with.

Cheers and thanks in advance.

E

Offline

#2 2017-05-26 14:11:33

igors233
Member
Registered: 2012-09-10
Posts: 234

Re: Rest Server with multiple interfaces

NoSaint50 wrote:

I found the Third Party folder with George's Rest-tester and am wondering how to go about adding more interfaces to this. I follow what's happening in the RestMethodsInterfaceUnit and RestServerMethodsUnit, so I'm assuming I'd add 2 more units, say TestInterfaceUnit and TestUnit.
The TRestServer.Initialize call in RestServerUnit is where things start getting difficult. Do I need to create a second TSQLModel and TSQLRestServerFullMemory, or just repeat these calls with new constants ROOT_NAME2 and SERVICE_INSTANCE_IMPLEMENTATION" ?? Is this the best way to tackle this if eventually I'd have loads of Interfaces for different areas of an application? Is there an Interface "collection" that could be used?

I'm not completly sure what you're after but you can have multiple REST servers (models, root) within one TSQLHttpServer, take a look at
TSQLHttpServer.Create(const aPort: AnsiString; const aServers: array of TSQLRestServer;...
within mORMotHttpServer.pas, it's also good idea to read what available for TSQLHttpServer inside documentation.
Also take a look at this thread: https://synopse.info/forum/viewtopic.php?id=3942, it has some of the things explained.

Last edited by igors233 (2017-05-26 14:12:24)

Offline

#3 2017-05-26 19:11:24

NoSaint50
Member
Registered: 2017-05-26
Posts: 4

Re: Rest Server with multiple interfaces

Hi again,

That's handy to know ... and I'll go check out the links.

I'm thinking of eventually having several interfaces for different areas of an application ... PurchaseInterface, ClientInterface, ProductInterface and so on. I'm not 100% sure how these get "published" to the REST Server so a client could invoke the relevant functions and how these scale up to handle several hundred users.
The last couple of hours looking at examples have been fairly educational - it just takes a little time getting up to speed on where the magic happens and how best to structure everything.

Thanks for the tips though.

cheers

E

Offline

#4 2017-05-26 22:56:53

igors233
Member
Registered: 2012-09-10
Posts: 234

Re: Rest Server with multiple interfaces

> I'm thinking of eventually having several interfaces for different areas of an application ... PurchaseInterface, ClientInterface, ProductInterface
>  and so on. I'm not 100% sure how these get "published" to the REST Server so a client could invoke the relevant

Basically each of those will have it's own root, like
https://mysite.com/purchase/
https://mysite.com/client/
https://mysite.com/product/

And if you use like method approach then address would be something like https://mysite.com/purchase/neworder/ where client posts new order data.

> functions and how these scale up to handle several hundred users.

All three of them are handled in Windows kernel (http.sys) and it routes calls to appropriate rest servers on your side and then rest server route it to particular method. It works fairly well and stable, unless you have some kind of slowness within the database you can handle a large number of concurrent clients.

> The last couple of hours looking at examples have been fairly educational - it just takes a little time getting up to speed on where
> the magic happens and how best to structure everything.

Just be patient, it will take some time to grasp it all.

Offline

Board footer

Powered by FluxBB