Stumps.FallbackResponseHandler.ProcessRequest C# (CSharp) Method

ProcessRequest() public method

Processes an incoming HTTP request.
is null.
public ProcessRequest ( IStumpsHttpContext context ) : Task
context IStumpsHttpContext The representing both the incoming request and the response.
return Task
        public async Task<ProcessHandlerResult> ProcessRequest(IStumpsHttpContext context)
        {

            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            context.Response.Headers.Clear();
            context.Response.ClearBody();
            context.Response.StatusCode = _statusCode;
            context.Response.StatusDescription = _statusCodeDescription;

            var stumpsResponse = context.Response as StumpsHttpResponse;

            if (stumpsResponse != null)
            {
                stumpsResponse.Origin = _origin;
            }

            if (this.ContextProcessed != null)
            {
                this.ContextProcessed(this, new StumpsContextEventArgs(context));
            }

            return ProcessHandlerResult.Terminate;

        }

Usage Example

コード例 #1
0
        public void ProcessRequest_WithNullContext_ThrowsException()
        {
            var handler = new FallbackResponseHandler(FallbackResponse.Http404NotFound);

            Assert.That(
                async () => await handler.ProcessRequest(null),
                Throws.Exception.TypeOf<ArgumentNullException>().With.Property("ParamName").EqualTo("context"));
        }
All Usage Examples Of Stumps.FallbackResponseHandler::ProcessRequest