#2 mORMot 1 » Authentication usage » 2016-06-20 12:11:37

markus_ja
Replies: 2

Hello,

I feel lost with the authentication process. I tried all samples but couldn't figure out how to use authentication, with TSQlRestServerFullMemory.

My Server Code on start up (it's just a sample):

procedure TForm1.FormCreate(Sender: TObject);
begin
  _tableModel := TSQLModel.Create([],'root');
  _restServer := TMyRestServer.Create(_tableModel, true); //TSQlRestServerFullMemory

  _server := TSQLHttpServer.Create('888', [_restServer], '+', HTTP_DEFAULT_MODE);
  _server.AccessControlAllowOrigin := '*';
end;
TMyRestServer = class(TSQlRestServerFullMemory)
  published
    procedure Test(Ctxt: TSQLRestServerURIContext);
  end;

procedure TMyRestServer.Test(Ctxt: TSQLRestServerURIContext);
begin
  case Ctxt.Method of
    mGET:
      Ctxt.Returns('test');
  end;
end;

Where do I specify, which users (with password) have permissions to log in and when the session expires? Actually, I want to load all the registered users from my database.


Furthermore, for the client I use SmartMobileStudio. I invoke my rest server directly with the REST class in SMS using the URI with all required parameters. What params do I need to send to the server as well, in order my rest call is accepted?

e.g.

REST['http://localhost:888/root/', 'test']
  .OnDone(myOnDoneHandler)
  .Param('filter', myFilter)
  .Get;

#3 Re: mORMot 1 » How to access PUT data in TSQLRestServerFullMemory class » 2016-05-28 07:49:34

Oh ... I just saw it is Ctxt.Call^.InBody.
Since I am using Lazarus, I have to use the pointer operator ^ to access its memebers, where Delphi has some compiler magic.

#4 mORMot 1 » How to access PUT data in TSQLRestServerFullMemory class » 2016-05-28 07:43:17

markus_ja
Replies: 1

Hello,

I am using the TSQLRestServerFullMemory class to communicate with the client. I can resivce data from the server (GET), but don't know how I can access the input data (POST/PUT/DELETE), send by the client.

I have the following code:

TTableService = class(TSQLRestServerFullMemory)
published
  procedure Article(Ctxt: TSQLRestServerURIContext);
end;

procedure TTableService.Article(Ctxt: TSQLRestServerURIContext);
begin
  case Ctxt.Method of
    mGET: Ctxt.Returns(TTblArticle.Read);
    mPUT: ???;
    mPOST: ???;
    mDELETE: ???;
  else
    SetErrorMessage(Ctxt, Format(RS_ContextMethodNotSupported, [Ord(Ctxt.Method)]));
  end;
end;

#6 Re: mORMot 1 » Help on how to use mORMot framework in lazarus » 2016-05-25 07:34:53

I have added all 3 pathes as mentioned in the documentation, but when I use the mormot unit, I get the error message: "Cannot open include file "Synopse.inc" in the mormot.pas file.

That file is present and that path is also in the project options. Any hint, why it cannot open that file?

#8 mORMot 1 » Help on how to use mORMot framework in lazarus » 2016-05-25 06:17:40

markus_ja
Replies: 5

Hello,

I am very new to lazarus, and don't know how to set the search and library path for the mORMot files. I read in the lazarzs forums, that I cannot set such pathes!?
So how to tell lazarus, where the files are located in order my project can find it?

thanks,
Markus

#9 Re: mORMot 1 » Best practice when database schema will change in future » 2015-11-20 13:58:49

Do you mean, instead of using TSQLRecord and publishing that table, I shall implenent my own published method on a derived TSQlRestServerFullMemory like in the example: 06 - Remote JSON REST Service?
How to I implement the GET/PUT/POST/DELETE commants sent by the client, do perform ny own DB access?

I am very new to the whole concept of SOA and REST and mORMot and providing data to clients. Therefore, it's bit hard for me where I shall start.

#10 mORMot 1 » Best practice when database schema will change in future » 2015-11-20 10:30:35

markus_ja
Replies: 4

Hello,

I actually just want to share my database data (firebird) over the internet using REST and JSON (Client: Android using Android Studio).
Using mORMot seems to make that task pretty easy. But I wonder, what happens when my tables are going to change in the future, and old clients want to access "altered" tables, which will change in future versions of the server?

E.g.:
Current table name on server: TABLE_V1 => the corresponding REST uri for the client would be: http://myserver.com/root/table_v1
Altered table name on server in the future: TABLE_V2 => The server is then listening on: http://myserver.com/root/table_v2
(Subsquently, the table name stays the same, but new columns are added or column names are changed)

So my question is:
How to prepare my server to be ready for such changes in the future? E.g. redirecting OLD client request from http://myserver.com/root/table_v1 to ../table_v2 and still returning old JSON format records (data)?

Thanks,
markus

Board footer

Powered by FluxBB