#1 2020-07-22 23:26:23

GustavoM
Member
Registered: 2020-07-22
Posts: 5

REST Server in Delphi 5

First of all, sorry for my english. :-(

Second, congratulations for the excelent component you have! I read almost all of the documentation and it is clear that you LOVE what you did. Congratulations again!

And third...

I have an application in Delphi 5 and I need to make a small REST server. I don´t need to use any database components of mORMot. I just need to make something similar to the sample "06 - Remote JSON REST Service". May be a bit more complex, but that is the basic idea. Instead of the procedure TServiceServer.Sum, I can write my own procedures to obtain the results to GET commands.

The problem is... I couldn´t compile mORMot in Delphi 5. I tried with sample 06 and some others and it is impossible to compile. I always get errors. I changed some lines, commented some lines... and again errors. I know mORMot is guaranteed to work on Delphi 6 or newer, but I also know some components work also in Delphi 5 (like SynPDF).

I also tried compiling old releases of mORMot (2020-07-17, 1.18.4952, 1.18.2975, 2012-03-08).

So... the question is... is there a way to compile a simple REST server in Delphi 5? Thanks in advance!

Offline

#2 2020-07-23 05:46:28

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

Re: REST Server in Delphi 5

The REST server part never was Delphi 5 compatible.
Only the cross-platform client units can be used. So no REST server...

In practice, we are not able to support Delphi 5 any more.
The Delphi 5 compiler refuses to compile the mORMot trunk since a few months (some obscure internal errors), and we were not able to circumvent it...
sad

You may try to compile SynCrtSock, and use its raw HTTP server classes...
Take a look at the "09 - HttpApi web server" sample.

Offline

#3 2020-07-24 00:27:23

GustavoM
Member
Registered: 2020-07-22
Posts: 5

Re: REST Server in Delphi 5

Thank you very much for your answer. I tried "09 - HttpApi web server" sample,  I could compile it and it works!

I think I can manage with that to do what I need. I will try... Thank you very much again!

Offline

#4 2020-07-24 08:11:47

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

Re: REST Server in Delphi 5

The good part is that if you use the http.sys API server of SynCrtSock, you will have a very proven and efficient Web Server on Windows, to expose your Delphi 5 application.
But a lot of JSON powerplate is to be done by hand...

Offline

#5 2020-07-27 18:10:42

GustavoM
Member
Registered: 2020-07-22
Posts: 5

Re: REST Server in Delphi 5

Yes, I know I will have to do a lot of JSON work by hand. But if this works it will be worth.

This is not something I have to do just now. When it comes the moment, I will see... :-)

Thanks again.

Offline

#6 2020-07-27 21:03:18

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

Re: REST Server in Delphi 5

You can use the JSON generator of our cross-platform client units.
It allows late binding and is fast enough in practice for most simple use.

Offline

#7 2021-06-14 01:28:54

GustavoM
Member
Registered: 2020-07-22
Posts: 5

Re: REST Server in Delphi 5

Hello!

Almost one year ago, I asked some questions about making a small REST server with Delphi 5. You suggested to compile SynCrtSock and to take a look at the "09 - HttpApi web server" sample. I did that and could compile it. I also said that it was something I would have to do in the future. Well... the future arrived! :-)

Now I am trying to do this and I have a new doubt. I want to add authentication. I just want that when a user tries to access the server, he should have to indicate a user name and a password. I read the documentation but I can´t find how to do it using THttpApiServer and THttpServerRequest (the components used in sample 09).

Can you please tell me how can I do this? Thanks in advance!

Offline

#8 2021-06-14 07:40:24

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

Re: REST Server in Delphi 5

You could handle basic authentication, over TLS/HTTPS for instance.

There is no built-in implementation of it in SynCrtSock for socket-based THttpServer: you have to implement the expected header with base-64 decoding to check the password.

But there is some built-in authentication via THttpApiServer.SetAuthenticationSchemes() in SynCrtSock.

Offline

#9 2021-06-15 03:44:11

GustavoM
Member
Registered: 2020-07-22
Posts: 5

Re: REST Server in Delphi 5

Thank you!

I tried to do something with THttpApiServer.SetAuthenticationSchemes() but I couldn´t. May be I didn´t understand how to do it.

I think I will try just to use parameters for username and password.

Offline

Board footer

Powered by FluxBB