I am not sure what the side-effects of IRequest.UseBufferedStream = true are on the other operations and services in my service, since the default is: IRequest.UseBufferedStream = false
So I would like to limit any effects on other service operations.
So my question is: is it possible to somehow limit which kinds of requests I set IRequest.UseBufferedStream = true on?
I know I cannot look at the IRequest.Dto, because it is not yet deserialised when a PreRequestFilter is run.
But I can say that the only DTO’s and service operations for which this is only relevant to are known and contained in a single service.
What would be the next best way to tell whether the request is bound for a specific service, operation or DTO?
Actually , is there anyway to tell what service the current request is bound for, rather than the type of the request?
Or even better, tell whether the DTO has a specific AuthenticateAttribute on it?
The only requests that needs this filter are in a single service, and they all look like this:
[Authenticate(HmacAuthProvider.Name)]
public void Post(MyDto1 body)
{
...
}
[Authenticate(HmacAuthProvider.Name)]
public void Get(MyDto2 body)
{
...
}
You need the Request Type of the Request to find out what the Service Type is, e.g:
var serviceType = HostContext.Metadata.GetServiceTypeByRequest(requestType);
You can try looking up the Route manually with:
var restPath = HostContext.ServiceController.GetRestPathForRequest(httpReq.Verb, httpReq.PathInfo);
var requestType = restPath.RequestType;
BTW you can just annotate your Service once, instead of each Service individually, e.g:
[Authenticate(HmacAuthProvider.Name)]
public class MyAuthServices : Service
{
public void Post(MyDto1 body) => ...;
public void Get(MyDto2 body) => ...;
}