public ITrace ForRequest(IRazorRequest req)
        {
            // Just loop around if we reach the end of the request id space.
            Interlocked.CompareExchange(ref _nextId, 0, Int64.MaxValue);

            return(new OwinTrace(req, Interlocked.Increment(ref _nextId)));
        }
Beispiel #2
0
        public Task<RouteResult> Route(IRazorRequest request, ITrace tracer)
        {
            Requires.NotNull(request, "request");
            Requires.NotNull(tracer, "tracer");

            // This is so slooooow!
            IFileInfo file;
            string[] pathFragments = request.Path.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
            for (int end = pathFragments.Length - 1; end >= 0; end--)
            {
                Tuple<string, string> candidate = CreateCandidate(pathFragments, end);
                file = ResolveCandidate(candidate.Item1.Replace('/', Path.DirectorySeparatorChar));
                if (file != null)
                {
                    return Task.FromResult(RouteResult.Successful(file, candidate.Item2));
                }
            }
            file = ResolveCandidate(String.Empty);
            if (file != null)
            {
                return Task.FromResult(RouteResult.Successful(file, request.Path.TrimStart('/')));
            }
            else
            {
                return Task.FromResult(RouteResult.Failed());
            }
        }
Beispiel #3
0
        public Task <RouteResult> Route(IRazorRequest request, ITrace tracer)
        {
            Requires.NotNull(request, "request");
            Requires.NotNull(tracer, "tracer");

            // This is so slooooow!
            IFileInfo file;

            string[] pathFragments = request.Path.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
            for (int end = pathFragments.Length - 1; end >= 0; end--)
            {
                Tuple <string, string> candidate = CreateCandidate(pathFragments, end);
                file = ResolveCandidate(candidate.Item1.Replace('/', Path.DirectorySeparatorChar));
                if (file != null)
                {
                    return(Task.FromResult(RouteResult.Successful(file, candidate.Item2)));
                }
            }
            file = ResolveCandidate(String.Empty);
            if (file != null)
            {
                return(Task.FromResult(RouteResult.Successful(file, request.Path.TrimStart('/'))));
            }
            else
            {
                return(Task.FromResult(RouteResult.Failed()));
            }
        }
Beispiel #4
0
            public async Task Returns200ResponseAndExecutesPage()
            {
                // Arrange
                var           page     = new Mock <IRazorPage>();
                var           executor = new DefaultPageExecutor();
                IRazorRequest request  = TestData.CreateRequest(path: "/Bar");

                page.Setup(p => p.Run(It.IsAny <IRazorRequest>(), It.IsAny <IRazorResponse>()))
                .Returns((IRazorRequest req, IRazorResponse res) =>
                {
                    res.StatusCode   = 200;
                    res.ReasonPhrase = "All good bro";
                    return(Task.FromResult(new object()));
                });

                // Act
                await executor.Execute(page.Object, request.Environment, NullTrace.Instance);

                var response = new RazorResponse(request.Environment);

                // Assert
                // page.Verify(p => p.Run(request, response));
                Assert.Equal(200, response.StatusCode);
                Assert.Equal("All good bro", response.ReasonPhrase);
            }
        public ITrace ForRequest(IRazorRequest req)
        {
            // Just loop around if we reach the end of the request id space.
            Interlocked.CompareExchange(ref _nextId, 0, Int64.MaxValue);

            return new OwinTrace(req, Interlocked.Increment(ref _nextId));
        }
Beispiel #6
0
 public Task Run(IRazorRequest request, IRazorResponse response)
 {
     Request  = request;
     Response = response;
     Output   = new ResponseWriter(response);
     Execute();
     return(Task.FromResult(new object()));
 }
Beispiel #7
0
 public Task Run(IRazorRequest request, IRazorResponse response)
 {
     Request = request;
     Response = response;
     Output = new ResponseWriter(response);
     Execute();
     return Task.FromResult(new object());
 }
 public ITrace ForRequest(IRazorRequest req)
 {
     return NullTrace.Instance;
 }
Beispiel #9
0
 public ITrace ForRequest(IRazorRequest req)
 {
     return(NullTrace.Instance);
 }
 public Task Run(IRazorRequest request, IRazorResponse response)
 {
     throw new NotImplementedException();
 }
Beispiel #11
0
 public OwinTrace(IRazorRequest request, long id)
 {
     RequestId = id;
     Request   = request;
 }
 public Task Run(IRazorRequest request, IRazorResponse response)
 {
     throw new NotImplementedException();
 }
Beispiel #13
0
 public OwinTrace(IRazorRequest request, long id)
 {
     RequestId = id;
     Request = request;
 }