You are not logged in.
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
You can add URI redirection at HTTP server level, in mORMot.
Offline
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
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
Do you try to rewrite GET to POST with urmPost?
Server.Route.Get('/Perfiles', 'root/PerfilService.getperfilesusuario', urmPost);
Offline
I already try that and it was the same it didnt work
Offline
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