Add RLS server side

Is it possible to extend the SQL command on the server side,
to add RLS (PostgreSQL) for example?
I've tried this so far, but it has no effect:

procedure(C: THttpServerContext; Next: THttpServerProc)
command:='set app.rls_current_school = '123';';
command:=command+TEncoding.UTF8.GetString(C.Request.Content, 4, C.Request.ContentLength-4);
C.Request.ContentStream := TBytesStream.Create(TEncoding.UTF8.GetBytes(command));

Thank you for an answer

When you read C.Request.Content, the content is saved in a cache and is not reloaded anymore. Thus changing the stream doesn't change anything. Change your code to read directly from original ContentStream, something like this (untested):

command:='set app.rls_current_school = '123';';
NewContentStream := TBytesStream.Create(TEncoding.UTF8.GetBytes(command));
CopyToStream(C.Request.ContentStream, NewContentStream);
C.Request.ContentStream := NewContentStream;

Then in CopyToStream you copy the content from one string to another, preferably using buffers as C.Request.Content.Size might not be set in the stream (in the case of chunked contents).