예제 #1
0
        protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines)
        {
            if (PlatformService.IsUnix)
            {
                HelpService.AsyncInitialize();
            }

            pipelines.BeforeRequest.AddItemToStartOfPipeline(ctx =>
            {
                var stopwatch          = new Stopwatch();
                ctx.Items["stopwatch"] = stopwatch;
                stopwatch.Start();
                return(null);
            });

            pipelines.AfterRequest.AddItemToEndOfPipeline(ctx =>
            {
                var stopwatch = (Stopwatch)ctx.Items["stopwatch"];
                stopwatch.Stop();
                Console.WriteLine(ctx.Request.Path + " " + stopwatch.ElapsedMilliseconds + "ms");
            });

            pipelines.OnError.AddItemToEndOfPipeline((ctx, ex) =>
            {
                Console.WriteLine(ex);
                return(null);
            });
        }
예제 #2
0
        protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines)
        {
            if (PlatformService.IsUnix)
            {
                HelpService.AsyncInitialize();
            }

            pipelines.BeforeRequest.AddItemToStartOfPipeline(StopWatchStart);
            pipelines.AfterRequest.AddItemToEndOfPipeline(StopWatchStop);

            if (_verbose)
            {
                pipelines.BeforeRequest.AddItemToStartOfPipeline(LogRequest);
                pipelines.AfterRequest.AddItemToStartOfPipeline(LogResponse);
            }

            pipelines.OnError.AddItemToEndOfPipeline((ctx, ex) =>
            {
                Console.WriteLine(ex);
                return(null);
            });
        }
예제 #3
0
        protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines)
        {
            if (PlatformService.IsUnix)
            {
                HelpService.AsyncInitialize();
            }

            pipelines.BeforeRequest += (ctx) => StopWatchStart(ctx);
            pipelines.AfterRequest  += (ctx) => StopWatchStop(ctx);

            if (_logger.Verbosity == Verbosity.Verbose)
            {
                pipelines.BeforeRequest += (ctx) => LogRequest(ctx);
                pipelines.AfterRequest  += (ctx) => LogResponse(ctx);
            }

            pipelines.OnError.AddItemToEndOfPipeline((ctx, ex) =>
            {
                _logger.Error(ex);
                return(null);
            });
        }