#2 Re: mORMot 2 » Can someone help me figure out how to change the url for my endpoints » 2025-05-13 16:03:18

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.

#3 Re: mORMot 2 » Can someone help me figure out how to change the url for my endpoints » 2025-05-12 18:04:18

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;

#4 mORMot 2 » Can someone help me figure out how to change the url for my endpoints » 2025-05-12 16:06:01

Gabian04
Replies: 6

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?.

#5 Re: mORMot 2 » I have a problem getting my Json without the Result: » 2025-05-11 21:14:46

Thanks a lot. That fix it I'll keep that in mind and do my other services as procedures.

#6 Re: mORMot 2 » I have a problem getting my Json without the Result: » 2025-05-09 20:16:05

OK so this is how I have my service declared
t:=restServer.ServiceRegister(TPerfilService,[TypeInfo(IPerfilService)],sicShared);
t.ResultAsJsonObjectWithoutResult:=true;
t.SetWholeOptions([optResultAsJsonObjectWithoutResult]);

And the result did change from and JsonArray to a JsonObject but the result didnt get removed. I have tried moving other options around and changing the return type of the service but nothing worked. What am I doing wrong?

#7 mORMot 2 » I have a problem getting my Json without the Result: » 2025-05-09 18:52:41

Gabian04
Replies: 6

Hi I have a service-method server and I am trying to get the json without the Result: wrapper. The problem is that even with using the ResultAsJsonObjectWithoutResult:=true; its not working. Can anyone help me.

Board footer

Powered by FluxBB