Beispiel #1
0
        private void ProcessRequest(Request request, IResponseBuffer responseBuffer)
        {
            SetupRouter(_onBefore());
            var router = GetRouter();

            try
            {
                if (router.CanRoute(request.Path))
                {
                    var actualResponse = router.Route(request);
                    responseBuffer.SetContentsOfBufferTo(actualResponse);
                }
                else
                {
                    responseBuffer.SetContentsOfBufferTo(NewResponseWithStatus(404));
                }
            }
            catch (Exception e)
            {
                _exceptions.Add(e);
                responseBuffer.SetContentsOfBufferTo(
                    NewResponseWithStatus(500).BodyFromString(_exceptions.First().ToString())
                    );
            }
            finally
            {
                responseBuffer.Flush();
                _onAfter(_onBefore());
            }
        }
 public void HandleRequest(Request request, IResponseBuffer buffer)
 {
     _requests.Add(request);
     buffer.SetContentsOfBufferTo(_respondWith);
     buffer.Flush();
 }
 private void ProcessRequest(Request request, IResponseBuffer responseBuffer)
 {
     _lastRequest = request;
     responseBuffer.SetContentsOfBufferTo(_nextResponse);
     responseBuffer.Flush();
 }