#1 2025-05-12 16:06:01

Gabian04
Member
Registered: 2025-05-09
Posts: 7

Can someone help me figure out how to change the url for my endpoints

Hi I am doing a interface-service method server. I am migrating a server from another language and the endpoints have a certain structure I wouldnt want to change. I would like to change it from something like this http://localhost:8080/root/Service.Method to http://159.182.150.36:9290/root/method. Is it possible to skip the service in the URI?.

Last edited by Gabian04 (2025-05-12 16:07:01)

Offline

#2 2025-05-12 16:45:59

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

Re: Can someone help me figure out how to change the url for my endpoints

You can add URI redirection at HTTP server level, in mORMot.

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

Offline

#3 2025-05-12 18:04:18

Gabian04
Member
Registered: 2025-05-09
Posts: 7

Re: Can someone help me figure out how to change the url for my endpoints

restServer.ServiceRegister(TPerfilService,[TypeInfo(IPerfilService)],sicShared);

Server:= TSQLHTTPServer.Create('8080',[restServer]);
Server.Route.Get('/Perfiles', 'root/PerfilService.getperfilesusuario');

Hi I read the article and I added this to my server but it still only works with the full route. Did I misunderstood how it works? This is how my service is defined:

procedure TPerfilService.getperfilesusuario(out Resultado, Descripcion: string;
  out Datos: RawJson);
var
  dao:TDAO;
  Lista:specialize TObjectList<TPerfil>;
  jsonData:TJSONObject;
  docArray:TJSONArray;
  perfil:TPerfil;
  response:TResponse;
begin
    dao:=TDAO.Create;
    Lista:=dao.GetPerfilesUsuario;
    docArray:=TJSONArray.Create();
    for perfil in Lista do begin
        jsonData:=TJSONObject.Create();
        jsonData.Add('Perfil',perfil.PERFIL.ToString);
        jsonData.Add('Nombre',perfil.NOMBRE);
        jsonData.Add('Permisos',perfil.PERMISOS);
        docArray.add(jsonData);
    end;
    Resultado:='0'
    Descripcion:='Operacion Correcta'
    Datos:=docArray.AsJSON;
end;

Offline

#4 2025-05-13 16:03:18

Gabian04
Member
Registered: 2025-05-09
Posts: 7

Re: Can someone help me figure out how to change the url for my endpoints

I have been reading the code and methods for hours but I still can't find how. I think it is simple but I cant find what I am doing wrong. I enter the code to see different methods like Route, and Router in the rest server but I cant figure out how to change the endpoint. With route in the http server it registers the get but it dosent work when I am calling it. I would appreciate some help if anyone knows how to do it.

Offline

#5 2025-05-13 23:19:00

ttomas
Member
Registered: 2013-03-08
Posts: 142

Re: Can someone help me figure out how to change the url for my endpoints

Do you try to rewrite GET to POST with urmPost?

Server.Route.Get('/Perfiles', 'root/PerfilService.getperfilesusuario', urmPost);

Offline

#6 2025-05-13 23:29:58

Gabian04
Member
Registered: 2025-05-09
Posts: 7

Re: Can someone help me figure out how to change the url for my endpoints

I already try that and it was the same it didnt work

Offline

#7 2025-05-14 00:05:35

ttomas
Member
Registered: 2013-03-08
Posts: 142

Re: Can someone help me figure out how to change the url for my endpoints

Typo missing / before root?
'/root/PerfilService.getperfilesusuario'
edited:
just tested work with and without '/', check some typo

Last edited by ttomas (2025-05-14 00:16:03)

Offline

Board footer

Powered by FluxBB