public Task Handle(IHttpContext context, Func <Task> next)
        {
            var result = _method(context);

            if (result != null)
            {
                context.Response = StringHttpResponse.Create(result, contentType: _contentType);
                return(Task.Factory.GetCompleted());
            }

            return(next());
        }
Beispiel #2
0
 public ConstStringHttpRequestHandler(string text,
                                      HttpResponseCode code = HttpResponseCode.OK,
                                      string contentType    = "text/html; charset=utf-8",
                                      bool keepALive        = true)
 {
     Text        = text;
     ContentType = contentType;
     Response    = StringHttpResponse.Create(text,
                                             contentType: contentType,
                                             code: code,
                                             keepAlive: keepALive);
 }