#1 2025-10-16 13:12:44

koraycayiroglu
Member
Registered: 2017-02-03
Posts: 81

How to unregister a method?

Hi to everyone,

Looking for something like ServiceMethodUnRegister but couldn't find, how do i unregister a method at run-time? In my case, i am creating mvc applications with suburi on the fly for displaying a secure content, and it will dissmised itself at a certain time period. Mvc app freed but i can't use same suburi to create a new mvc app. Also, don't wanna use more custom suburi's, like timestamped, cause this means registering too many unnecessary suburi's to rest server.

Best regards

Offline

#2 2025-10-24 10:09:44

koraycayiroglu
Member
Registered: 2017-02-03
Posts: 81

Re: How to unregister a method?

it's seems there is not. Anyway, i found my own solution with a different approach. Never mind this question. Thanks.

Offline

#3 2025-10-28 12:12:51

pvn0
Member
From: Slovenia
Registered: 2018-02-12
Posts: 217

Re: How to unregister a method?

If you are referring to method based services you should not be adding or removing methods at runtime. It was not designed for it, also background logic is implemented using TDynArrayHashed which is not thread safe. I don't know what your solution is but if it's not jwt tokens it's probably a bad solution. Best regards

Last edited by pvn0 (2025-10-28 12:15:04)

Offline

#4 2025-10-28 13:46:51

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 15,261
Website

Re: How to unregister a method?

@pvn0 mORMot 2 does not use TDynArrayHashed but the TUriRouter dedicated class.

What you could do is hook before the regular routing with a callback at HTTP server level, then handle your custom routing at runtime from your own table.

Offline

#5 2025-10-28 15:52:45

pvn0
Member
From: Slovenia
Registered: 2018-02-12
Posts: 217

Re: How to unregister a method?

@ab mORMot 2 uses both

mORMot2/src/rest/mormot.rest.server.pas

function TRestServer.ServiceMethodRegister(aMethodName: RawUtf8;
...
  met := fPublishedMethods.AddUniqueName(aMethodName,
    'Duplicated published method name %.%', [obj, aMethodName], @result);
end;

fPublishedMethods is TDynArrayHashed and as result ServiceMethodRegister is not thread safe.
Sure its a remnant of mORMot 1 but is still used for several things. TUriRouter does not touch it, just the underlying dyn array so afaik could be removed to improve things.

Last edited by pvn0 (2025-10-28 16:02:45)

Offline

#6 2025-10-28 16:52:09

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 15,261
Website

Re: How to unregister a method?

You are right it is only to check for duplicates during the registration phase.

But not used during the routing itself.

Offline

#7 2025-10-31 13:17:53

koraycayiroglu
Member
Registered: 2017-02-03
Posts: 81

Re: How to unregister a method?

pvn0 wrote:

If you are referring to method based services you should not be adding or removing methods at runtime. It was not designed for it, also background logic is implemented using TDynArrayHashed which is not thread safe. I don't know what your solution is but if it's not jwt tokens it's probably a bad solution. Best regards

It's a mvc application without any authentication, there is no need for jwt or else. My solution is actually very simple. Used to use a mvc application for each instance, in this case eshot360 image with lots of js and images, to show user time limited content. I modified my code to use one mvc application and use an identifier as a uri parameter to load requested eshot360 content. using a orm class to make it time limited.

User make a api request to my server, server create's a new record for that request with the file and time info, returns a unique identifier, user mavigates to my mvc app with that identifier to see the content. after 5 minitues, that content will not be avaiablle.

It was just hard to show separate eshot360 content inside one mvc application, because it needed lots of rewrite url inside nginx to make it work. But the result is satisfying.

Offline

Board footer

Powered by FluxBB