예제 #1
0
        public void Configuration(Owin.IAppBuilder app)
        {
            app.EnableGlimpse();
            app.Map("/api", builder =>
            {
                builder.UseLightNode(new LightNodeOptions(AcceptVerbs.Get | AcceptVerbs.Post, new JilContentFormatter(), new GZipJilContentFormatter())
                {
                    OperationCoordinatorFactory       = new GlimpseProfilingOperationCoordinatorFactory(),
                    StreamWriteOption                 = StreamWriteOption.BufferAndWrite,
                    ParameterEnumAllowsFieldNameParse = true,
                    ErrorHandlingPolicy               = ErrorHandlingPolicy.ReturnInternalServerErrorIncludeErrorDetails,
                    OperationMissingHandlingPolicy    = OperationMissingHandlingPolicy.ReturnErrorStatusCodeIncludeErrorDetails,
                    Logger = LightNode.Diagnostics.LightNodeEventSource.Log
                });
            });
            app.Map("/swagger", builder =>
            {
                var xmlName = "LightNode.Sample.GlimpseUse.xml";
                var xmlPath = HttpContext.Current.Server.MapPath("~/bin/" + xmlName);
                //var xmlPath = System.AppDomain.CurrentDomain.BaseDirectory + "\\" + xmlName;

                builder.UseLightNodeSwagger(new Swagger.SwaggerOptions("LightNodeSample", "/api")
                {
                    XmlDocumentPath    = xmlPath,
                    IsEmitEnumAsString = true
                });
            });

            app.MapWhen(x => !x.Request.Path.Value.StartsWith("/Glimpse.axd", StringComparison.InvariantCultureIgnoreCase), builder =>
            {
                builder.Run(ctx =>
                {
                    ctx.Response.StatusCode = 404;
                    return(Task.FromResult(0));
                });
            });
        }