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

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

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: 79

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 Yesterday 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 (Yesterday 12:15:04)

Offline

#4 Yesterday 13:46:51

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 15,250
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 Yesterday 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 (Yesterday 16:02:45)

Offline

#6 Yesterday 16:52:09

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 15,250
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

Board footer

Powered by FluxBB