You are not logged in.
Pages: 1
Compile and execute the following program.
// e:\delphi12\bin\dcc32 servertest.pas -ID:\Borland\mORMot2\src -Ud:\Borland\mORMot2\src\core;d:\Borland\mORMot2\src\crypt;d:\Borland\mORMot2\src\db;d:\Borland\mORMot2\src\lib;d:\Borland\mORMot2\src\orm;d:\Borland\mORMot2\src\net;d:\Borland\mORMot2\src\soa;D:\Borland\mORMot2\src\rest -NSSystem;Winapi
program servertest;
{$apptype console}
{$I mormot.defines.inc}
uses
{$I mormot.uses.inc} // use FastMM4 on older versions of Delphi
Windows,
sysutils,
classes,
mormot.core.base,
mormot.core.log,
mormot.core.os,
mormot.core.rtti,
mormot.core.text,
mormot.net.http,
mormot.net.server,
mormot.rest.server,
mormot.rest.memserver,
mormot.rest.http.server;
type
TMyServer = class(TRestServerFullMemory)
public
constructor Create(const pmcRootName: RawUtf8); reintroduce;
published
procedure myapi(Ctxt: TRestServerUriContext);
end;
constructor TMyServer.Create(const pmcRootName: RawUtf8);
begin
CreateWithOwnModel([], FALSE, pmcRootName);
Server.CreateMissingTables;
end;
procedure TMyServer.myapi(Ctxt: TRestServerUriContext);
begin
Writeln('--- myapi ---');
WriteLn('1:', Ctxt.Call.Url);
WriteLn('2: Parameters: ', Ctxt.Parameters);
Ctxt.Returns('{"code": 0}', HTTP_SUCCESS, JSON_CONTENT_TYPE_HEADER_VAR);
end;
const
MYROOT = 'myapp';
procedure Run;
var
HttpServer: TRestHttpServer;
Server: TMyServer;
begin
Server := TMyServer.Create(MYROOT);
try
HttpServer := TRestHttpServer.Create('8888', [Server], '+', useHttpAsync);
try
HttpServer.Route.Get('/app/api', MYROOT + '/myapi');
HttpServer.AccessControlAllowOrigin := '*';
ConsoleWrite('Press [Enter] to quit'#13#10);
ConsoleWaitForEnterKey;
finally
HttpServer.Free;
end;
finally
Server.Free;
end;
end;
begin
with TSynlog.Family do
begin
Level := LOG_VERBOSE;
EchoToConsole := LOG_NFO + [sllDebug,sllDB,sllHTTP];
PerThreadLog := ptIdentifiedInOnFile;
NoFile := True;
end;
try
Run;
except
on E: Exception do
ConsoleShowFatalException(E);
end;
FreeConsole;
end.The results are as follows.
# servertest.exe
......
Press [Enter] to quit
--- myapi ---
1:myapp/myapi <--- routing: curl http://127.0.0.1:8888/app/api?q=abc
2: Parameters:
20251017 10372819 5 srvr mormot.rest.server.TRestServerRoutingRest(035f6390) Method GET myapi=200 out=11 in 940us
--- myapi ---
1:myapp/myapi?q=abc <--- no routing: curl http://127.0.0.1:8888/myapp/myapi?q=abc
2: Parameters: q=abc
20251017 10373228 - srvr mormot.rest.server.TRestServerRoutingRest(035f6390) Method GET myapi=200 out=11 in 1.88msOffline
You are right: the parameters were not reported to the rewritten URI.
Should be OK now with
https://github.com/synopse/mORMot2/commit/edb04e1a1
And with the associated regression tests as
https://github.com/synopse/mORMot2/commit/46ae49bbf
Offline
Great, it was solved so quickly, it works now.
Offline
Pages: 1