#1 2024-01-10 13:07:39

RaelB
Member
Registered: 2010-08-04
Posts: 57

Is it possible for me to define a service uri?

Hi,

For an interface-based service is it possible for me to define the uri endpoint?

E.g. the service is defined as

ISampleService = interface...

So the uri is going to be at root/SampleService

Is there a setting to modify this so that the service enpoint is at root/Sample?

Offline

#2 2024-01-10 20:46:05

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,603
Website

Re: Is it possible for me to define a service uri?

You can do this with the "Router" feature, at HTTP level.
You can "rewrite" the URI on the fly.

See https://blog.synopse.info/?post/2022/12 … -Christmas

Offline

#3 2024-01-15 03:01:02

jjwwang
Member
Registered: 2023-09-11
Posts: 6

Re: Is it possible for me to define a service uri?

TOrmModel.Create([TPerson], 'API');     //    API/SampleService

Offline

#4 2024-01-25 08:19:49

jjwwang
Member
Registered: 2023-09-11
Posts: 6

Re: Is it possible for me to define a service uri?

I followed ab's reply above and added some test code that I explored .


FHttpServer := TRestHttpServer.Create(APort, [FRestServer], '+', HTTP_DEFAULT_MODE, 32, secNone, '/' {aAdditionalUrl});

FHttpServer.Route.Rewrite(urmGet, '/', urmGet, '/myApi/myService/getTime');

Offline

Board footer

Powered by FluxBB