@@ -33,7 +33,7 @@ public async Task<bool> HandleJsonApiRouteAsync(HttpContext context, IServicePro
3333 if ( route == null ) return false ;
3434
3535 InitializeContext ( context , route ) ;
36- await CallController ( ) ;
36+ await CallController ( context ) ;
3737
3838 return true ;
3939 }
@@ -44,15 +44,15 @@ private void InitializeContext(HttpContext context, Route route)
4444 _jsonApiContext = new JsonApiContext ( context , route , dbContext , _jsonApiModelConfiguration ) ;
4545 }
4646
47- private async Task CallController ( )
47+ private async Task CallController ( HttpContext context )
4848 {
4949 var controller = _controllerBuilder . BuildController ( _jsonApiContext ) ;
5050
5151 var result = ActivateControllerMethod ( controller ) ;
5252
5353 result . Value = SerializeResult ( result . Value ) ;
5454
55- await SendResponse ( result ) ;
55+ await SendResponse ( context , result ) ;
5656 }
5757
5858 private ObjectResult ActivateControllerMethod ( IJsonApiController controller )
@@ -78,9 +78,8 @@ private object SerializeResult(object result)
7878 return result == null ? null : new JsonApiSerializer ( _jsonApiContext ) . ToJsonApiDocument ( result ) ;
7979 }
8080
81- private async Task SendResponse ( ObjectResult result )
81+ private async Task SendResponse ( HttpContext context , ObjectResult result )
8282 {
83- var context = _jsonApiContext . HttpContext ;
8483 context . Response . StatusCode = result . StatusCode ?? 500 ;
8584 context . Response . ContentType = "application/vnd.api+json" ;
8685 await context . Response . WriteAsync ( result . Value == null ? "" : result . Value . ToString ( ) , Encoding . UTF8 ) ;
0 commit comments