#1 2019-01-28 12:17:32

egold2005
Member
Registered: 2019-01-28
Posts: 16

Basic non-SQL RESTful service with mORMot

Hello,

I am new to this stuff and I am about to create a kind of proxy RESTful service with mORMot.

I saw some sample code and it always refers TSQLHttpServer component.

Is there a way I can create non-SQL server?

Any suggestions are greatly appreciated.

Thanx a lot.

Offline

#2 2019-01-28 13:07:36

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

Re: Basic non-SQL RESTful service with mORMot

Just use a void model.
That is, call TSQLServerFullMemory.CreateWithOwnModel([],false,'root') for /root URI.

Offline

#3 2019-01-28 13:36:50

egold2005
Member
Registered: 2019-01-28
Posts: 16

Re: Basic non-SQL RESTful service with mORMot

I modified the sample code like this. I do not have TSQLServerFullMemory class in my installation it seems...

When I run this, I get Access is denied. I think this is something to do with permissions....

Offline

#4 2019-01-28 13:37:33

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

Re: Basic non-SQL RESTful service with mORMot

It is TSQLRestServerFullMemory from mORMot.pas.

Offline

#5 2019-01-28 13:59:26

egold2005
Member
Registered: 2019-01-28
Posts: 16

Re: Basic non-SQL RESTful service with mORMot

Thank you, I got it running.

Now when I hit it at http://127.0.0.1:888/root I get

{
"errorCode":400,
"errorText":"Bad Request"
}

Where do I put the server logic?

Basically what I want to do is, determine the URI part, like "root" or "id1" or "id2" etc, and based on that ID to pass the request to another URL.

How do I go about that?

Thanx once again!

Offline

#6 2019-01-28 14:26:01

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

Re: Basic non-SQL RESTful service with mORMot

See the doc about services, e.g. method-based services or interface-based services.

For your use case, a method-based service may be good, since it gives full access to the HTTP context.

Offline

#7 2019-01-29 09:28:12

egold2005
Member
Registered: 2019-01-28
Posts: 16

Re: Basic non-SQL RESTful service with mORMot

Is there any demos/sample code available?


I am studying the docs and determined it would make sense to use TSQLRestServerRemoteDB to create a proxy, but the docs do not give enough information to get into that stuff...

Offline

#8 2019-01-29 09:47:06

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

Re: Basic non-SQL RESTful service with mORMot

TSQLRestServerRemoteDB is for remote SQL/ORM execution, but a RESTful service using high-level parameters, and returning JSON may be a better design.

There are samples of TSQLRestServerRemoteDB in the regression tests - see TestSQLite3.dpr.

Offline

#9 2019-01-29 10:55:23

egold2005
Member
Registered: 2019-01-28
Posts: 16

Re: Basic non-SQL RESTful service with mORMot

Okay, so for "better design" I inherit from TSQLRestServerFullMemory then, right?


What method do I override to deal with URI and redirect based on certain keywords found?

Also can I avoid "root" and have it like http://localhost:888/id1 etc?


Thank you.

Offline

#10 2019-01-29 11:15:53

egold2005
Member
Registered: 2019-01-28
Posts: 16

Re: Basic non-SQL RESTful service with mORMot

Okay, I have found 04 - HTTP Client-Server sample and I think this will get me started in correct direction.

Offline

Board footer

Powered by FluxBB