You are not logged in.
This is when I start service
....
aProps := TOleDBMSSQL2012ConnectionProperties.Create(servername, databasename, username, password);
ServerDB := TSQLRestServerWS.Create(Model, ':memory:', True);
ServerDB.OnAfterURI := OnServerAfterURI;
HttpServer := TSQLHttpServer.Create(port, [ServerDB]);
.....
Callback function
procedure TSM.OnServerAfterURI(Ctxt: TSQLRestServerURIContext);
begin
UT.Log(Ctxt.Call.InBody);
end;
UT.Log is just function that log text to file
This is what I got on output.txt
[
"{"onlyunread":"Y","size":9999999} 9999}"
There is newline after the bracket and garbage at the end which screw JSON format
This is what Angular actually sent
["{"onlyunread":"Y","size":9999999}"]
I just want to log what Angular sent me as input when they request API to mORMot.
PS. sorry for my bad English. I'm not a native speaker U_U
Offline
This is as expected: the input content, i.e. Call.InBody has been parsed in-place, with no memory allocation.
It is done as such for performance reasons.
If you want the input body untouched, use OnServerBeforeURI.
BTW the framework already has several ways of logging built-in - up to inside a database - so take a look at it before reinventing the wheel.
It will be much more powerful, and less invasive, than any other solution.
See https://synopse.info/files/html/Synopse … l#TITL_183
Offline
Information I want is
- InputBody
- InputHeader (i sent something useful from Angular) (UserAgent and RemoteIP also)
- OutputBody (so OnServerBeforeURI won't have this data like OnAfterBeforeURI?)
- MicroSecondsElapsed (OnAfterBeforeURI has Ctxt.MicroSecondsElapsed)
Actually I try AddInterceptor(), every data I want is all fine except just
Ctxt.MicroSecondsElapsed always 0
Offline