You are not logged in.
if it does ,the the uri will be more friendly
eg: domain/root
domain/root/admin/*
domain/root/api/*
i know the interface based service can do this ,but some times ,the method based service can be more flexable
Offline
At my old employer's place I wrote a method to replace all / in the URI with _ in the method calls. It was quite easy to do and I am planning on doing that again, as this improves readability for the user.
A call from domain/root/admin/user/add would go to the method admin_user_add.
Last edited by sakura (2021-04-28 04:43:05)
Offline
Just browsed through some old mORMot 1 test project, haven't done it in mORMot 2 yet. I created an override for TSQLRestServerURIContext.URIDecodeSOAByMethod. Retrieve the URI and URIBlobFieldName, replacing all / with _ and then checking like
type
TSQLRestServerAccess = class(TSQLRestServer);
...
MethodIndex := TSQLRestServerAccess(Server).fPublishedMethods.FindHashed(TestURI);
if MethodIndex >= 0 then
begin
URI := TestURI;
URIBlobFieldName := TestURIBlobFieldName;
Exit;
end;
Sorry, can't show all the rest here :-|
Offline
Good idea.
Please check https://synopse.info/fossil/info/86e1418dc1
Offline
why TMVCApplication can register a prefix like "blog" and then can access it with "root/blog/default" ? i mean, why this feture can not be used in ServiceMethodRegisterPublishedMethods ? any class with its published methods registed with ServiceMethodRegisterPublishedMethods with prefix ,eg "test" ,why we can not access it use "root/test/*" but "root/test*"?
Offline
my point is to group all method with one Prefix.
this is not to say i need to register a method with / slash or _ underline
Offline
Please check https://synopse.info/fossil/info/86e1418dc1
Works like a charm <3
ServiceManagerApp := TMypServiceManagerApplication.Create;
ServiceManagerApp.Start(RestServer, TypeInfo(IMypServiceManagerApplication));
RestServer.ServiceMethodRegisterPublishedMethods('svc_', ServiceManagerApp);
and the App-Class has methods like list_session and may now be called as domain/root/svc/list/session :-)
Offline
still get me wrong.
i mean TMVCApplication alreay have this feture , but any regular class registerd by RestServer.ServiceMethodRegisterPublishedMethods('some') dose not .
eg:
type
TMyDemoClass = class
published
procedure list(Ctxt:TSQLRestServerURIContext);
end;
var
_demo:TMyDemoClass ;
begin
... rest root eg :root
RestServer.ServiceMethodRegisterPublishedMethods('demo', _demo);
end;
then i need to access the list method by http://domain/root/demo/list
but with current mormot implemention , it only can be accessed by http://domain/root/demolist
Offline
ab wrote:Please check https://synopse.info/fossil/info/86e1418dc1
Works like a charm <3
ServiceManagerApp := TMypServiceManagerApplication.Create; ServiceManagerApp.Start(RestServer, TypeInfo(IMypServiceManagerApplication)); RestServer.ServiceMethodRegisterPublishedMethods('svc_', ServiceManagerApp);
and the App-Class has methods like list_session and may now be called as domain/root/svc/list/session :-)
your situation is too add one more level suburl to the mvc app above the TMVCRunOnRestServer.Create(Self,nil,'svc');
your case is to rewrite the list_session method to /list/session
Offline