You are not logged in.
Pages: 1
I have a interface based service:
ISomeService
Customers use this service, but now I would like to change it's name to ISuperSomeService, and for a moment provide the same service under two names, and in the future, the older interface will be removed.
Is it possible to do this without cloning the interface and class and without registering two, separated services? Some mapping or server routing?
Offline
No, here mapping is by convention by default, so by default you need to specify a new interface type (with its own GUID) to have diverse URI routing.
This should cover most of the use cases, in practice.
BUT you can define you own routing class, which is some work, but is possible.
See https://synopse.info/files/html/Synopse … #TITLE_447
Offline
I create this code:
type
TssRestRoutingREST = class(TSQLRestRoutingREST)
protected
function URIDecodeREST(): boolean; override;
public
end;
implementation
function TssRestRoutingREST.URIDecodeREST(): boolean;
var
l: Integer;
begin
Result := inherited URIDecodeREST;
l := Pos('SomeService', URI);
if l > 0 then
begin
URI := StringReplace(URI, 'SomeService', 'SuperSomeService', [rfReplaceAll]);
URIWithoutSignature := StringReplace(URIWithoutSignature, 'SomeService', 'SuperSomeService', [rfReplaceAll]);
end;
end;
and it works well, but is it the best method? What can be the side effects?
Offline
StringReplace() is not a good way of changing routing, since it may replace some content within inlined parameters, for instance.
So exact parsing may be a better idea.
Note also that you should better use StringReplaceAll() from SynCommons.pas, which is faster and works directly with RawUTF8 content, whereas StringReplace() induces a conversion to string.
Offline
I know about conversions and other issues, this is simple code to test solution.
Thanks for support!
Offline
Pages: 1