I suggest you ...

AsyncRequestFilters

We are creating a api that uses authorization attribute request filter in all paths(except login, of course). The attribute request for authorization to another system. Because request filters are sync the request is blocked and waiting for response at this point. A solution can be that request filters can returns a Task. Something like this:

public override Task ProcessRequestAsync(IRequest httpReq, IResponse httpRes, string operationName){


.....


return Task.Factory.ContinueWhenAll(appHost.ApplyAsyncRequestFilters(httpReq, httpRes, request),
tasks => httpRes.IsClosed ? null : GetResponse(httpReq, request))
.ContinueWith(tResponse => HandleResponse(tResponse.Result, response =>
{
if (appHost.ApplyResponseFilters(httpReq, httpRes, response))
return null;

if (responseContentType.Contains("jsv") && !string.IsNullOrEmpty(httpReq.QueryString["debug"]))
return WriteDebugResponse(httpRes, response);

if (doJsonp && !(response is CompressedResult))
return httpRes.WriteToResponse(httpReq, response, (callback + "(").ToUtf8Bytes(), ")".ToUtf8Bytes());

return httpRes.WriteToResponse(httpReq, response);
},
ex => !HostContext.Config.WriteErrorsToResponse
? ex.AsTaskException()
: HandleException(httpReq, httpRes, operationName, ex)));
}

1 vote
Vote
Sign in
Check!
(thinking…)
Reset
or sign in with
  • facebook
  • google
    Password icon
    I agree to the terms of service
    Signed in as (Sign out)
    You have left! (?) (thinking…)
    Josellm shared this idea  ·   ·  Admin →

    0 comments

    Sign in
    Check!
    (thinking…)
    Reset
    or sign in with
    • facebook
    • google
      Password icon
      I agree to the terms of service
      Signed in as (Sign out)
      Submitting...

      Feedback and Knowledge Base