You are not logged in.
Pages: 1
I have an example server:
TMyService = class(TInterfacedObject, IMyService)
public
procedure GetSomeData(const ID: integer; out Data: TSomeData);
procedure GetOtherData(const ID: integer; out Data: TOtherData);
end;
aModel := TSQLModel.Create([]);
try
// create a fast in-memory ORM server
aRest := TSQLRestServerFullMemory.Create(aModel,'',false,false);
try
aRest.ServiceRegister(TMyService,[TypeInfo(IMyService)],sicShared);
aServer := TSQLHttpServer.Create('8090', [aRest], '+', useHttpApiRegisteringURI);
try
writeln('Background server is running'#10);
write('Press [Enter] to close the server.');
ReadLn;
finally
aServer.Free;
end;
finally
aDB.Free;
end;
Is there a method/function to get from the server information about the available API in the form of a list of simple links for a specific service?
Something like that:
var
list : TStringList;
list := server.GetAvailableAPI('MyService');
//or maybe
list := aRest.GetAvailableAPI('https://server.adrress.com', 'MyService');
in list:
https://server.adrress.com:8090/root/MyService/GetSomeData
https://server.adrress.com:8090/root/MyService/GetOtherData
I particularly care about combining the http address (with port if <> 80 or 443), root address, service name and method name.
Offline
If you need to publish the services information to clients, check https://synopse.info/files/html/Synopse … #TITLE_482
For security reasons, there is no such thing as service discovery by default.
You have an optional TSQLRestServer.ServicesPublishedInterfaces/TSQLRestClientURI.ServicePublishOwnInterfaces mechanism, but it is not used on production yet on our side, so it may not be fully working.
And it is for a given TSQLRest (root/model).
If you need it, service discovery should be done in your own code, with a dedicated endpoint.
Note that what is expected with mORMot SOA is to use pascal interfaces as contract.
So interfaces (and their contract - see TInterfaceFactory.Contract) may be the main parameters in this service.
Anyway, service discovery is a mess usually in SOA - from our experiment.
A stateless architecture based on MicroServices is much better (IMHO).
Online
No, no, I need this for own convenience, only for internal use. For easier testing of clients written on other platforms.
Now I have to fold these addresses manually and I'm often wrong, I'm wasting many time.
Last edited by jaclas (2018-10-08 10:04:11)
Offline
Try to define all those addresses in code.
This is called https://en.wikipedia.org/wiki/Infrastructure_as_Code
You can use plain object pascal for it.
All my projects define all the servers as high-level Delphi types, like enumerates (one enum item per daemon, one per service, etc...), with all ports, and root defined in code.
Then client and server code uses this shared code as reference.
Online
Maybe we do not understand a bit.
I'm doing an HTTP server with several REST servers that have dozens of methods.
Now a colleague who is going to write a JS or PHP client asks me for an API.
What should I give him? Pascal files with data types and interface definitions?
Offline
Did you read https://synopse.info/files/html/Synopse … #TITLE_482 ?
You can generate the API documentation directly from the server - or even client code if you write the good Mustache template for the client language and libraries.
Online
I'm also interested in this subject.
The referred link is broken and title_482 no longer exists. What was the topic?
What is equivalent link in v2 documentation?
Offline
I guess the link is now https://synopse.info/files/html/Synopse … #TITLE_491
"17.2. Generating client wrappers"
Online
Pages: 1