private static object ReturnIdentity(FeatureContext featureContext) { return(featureContext); }
private async void ProcessRequestAsync(object requestContextObj) { var requestContext = requestContextObj as RequestContext; try { if (Stopping) { SetFatalResponse(requestContext, 503); return; } object context = null; Interlocked.Increment(ref _outstandingRequests); try { var featureContext = new FeatureContext(requestContext); context = _application.CreateContext(featureContext.Features); try { await _application.ProcessRequestAsync(context).SupressContext(); await featureContext.OnResponseStart(); } finally { await featureContext.OnCompleted(); } _application.DisposeContext(context, null); requestContext.Dispose(); } catch (Exception ex) { LogHelper.LogException(_logger, "ProcessRequestAsync", ex); _application.DisposeContext(context, ex); if (requestContext.Response.HasStarted) { requestContext.Abort(); } else { // We haven't sent a response yet, try to send a 500 Internal Server Error requestContext.Response.Headers.Clear(); SetFatalResponse(requestContext, 500); } } finally { if (Interlocked.Decrement(ref _outstandingRequests) == 0 && Stopping) { LogHelper.LogInfo(_logger, "All requests drained."); _shutdownSignal.TrySetResult(0); } } } catch (Exception ex) { LogHelper.LogException(_logger, "ProcessRequestAsync", ex); requestContext.Abort(); } }
public StandardFeatureCollection(FeatureContext featureContext) { _featureContext = featureContext; }