You are not logged in.
Pages: 1
Is it possible to work with TSQLRestServerURIContext different per interface? I would like to pass different headers per interface. I was using the Ctxt.Call.OutHead method but once defined for one interface all other interfaces on the same server will have the same header.
Offline
I don't understand how you set the output header.
It is a per-call context, so shouldn't affect the other interfaces.
Did you use the ServiceContext thread var?
See https://synopse.info/files/html/api-1.1 … ICECONTEXT
Offline
Hi Ab,
I used the server.OnAfterURI method because when I tried to use it by CurrentServiceContext even passing the value to the Request.Call.OutBody property had no effect.
Offline
Some working possibilities:
1. use a method-based service
2. or define a TServiceCustomAnswer record as function result
3. or properly write your OnAfterURI event to only change the header for your interface, checking Ctxt.ServiceMethod^.InterfaceDotMethodName (if Ctxt.ServiceMethod is not nil)
Offline
Hi Ab,
Thanks for the tips, I did as follows put TServiceCustomAnswer as a result of my function and it worked as I wanted.
fTotalRows:= aPagParam.totalrows;
TDocVariant.NewFast(response);
TDocVariantData(response).AddValue('Result',res);
for i:= Low(Data) to High(Data) do
TDocVariantData(response).A_['Data'].AddItem(Data[i]);
Result.Content:= VariantSaveJSON(response);
result.Header:= Trim(
'totalrows: '+IntToString(fTotalRows));
See I'm forming content with DocVariant. My question is if this is the most correct way to format a DocVariant with TVariantDynArray? In this case the variable Data is TVariantDynArray and response is docvariant.
Offline
Ok I modified, this is for array mounting is correct? Is there a way to pass a TVariantDynArray directly?
When you say mime type are you referring to application / json? Is this not standard in every mormot answer?
Last edited by fabiovip2019 (2019-12-12 12:25:31)
Offline
Pages: 1