Beispiel #1
0
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
        public void Configuration(Owin.IAppBuilder app)
#pragma warning restore CS1591 // Missing XML comment for publicly visible type or member
        {
            app.Map("/api", builder =>
            {
                builder.UseLightNode(new LightNodeOptions(AcceptVerbs.Get | AcceptVerbs.Post, new JilContentFormatter(), new GZipJilContentFormatter())
                {
                    StreamWriteOption = StreamWriteOption.BufferAndWrite,
                    ParameterEnumAllowsFieldNameParse = true,
                    ErrorHandlingPolicy            = ErrorHandlingPolicy.ReturnInternalServerErrorIncludeErrorDetails,
                    OperationMissingHandlingPolicy = OperationMissingHandlingPolicy.ReturnErrorStatusCodeIncludeErrorDetails,
                });
            });
            app.Map("/swagger", builder =>
            {
                var xmlName = "LightNode.Sample.Server.SelfHost.xml";
                var xmlPath = System.AppDomain.CurrentDomain.BaseDirectory + "\\" + xmlName;

                builder.UseLightNodeSwagger(new Swagger.SwaggerOptions("LightNodeSample", "/api")
                {
                    XmlDocumentPath    = xmlPath,
                    IsEmitEnumAsString = true
                });
            });
        }
Beispiel #2
0
        public static IAppBuilder UseMapDashboard <T>(
            this IAppBuilder app,
            string pathMatch       = "/dashboard",
            T options              = default(T),
            RouteCollection routes = null,
            IEnumerable <IDashboardAuthorizationFilter> authorization = null
            ) where T : class, new()
        {
            if (app == null)
            {
                throw new ArgumentNullException(nameof(app));
            }
            if (pathMatch == null)
            {
                throw new ArgumentNullException(nameof(pathMatch));
            }

#if !NETFULL
            var services = app.ApplicationServices;

            options       = options ?? services.GetService <T>() ?? new T();
            routes        = routes ?? services.GetRequiredService <RouteCollection>();
            authorization = authorization ?? services.GetServices <IDashboardAuthorizationFilter>();

            app.Map(new PathString(pathMatch), x => x.UseMiddleware <AspNetCoreFileManagerMiddleware <T> >(options, authorization, routes));
#else
            if (routes == null)
            {
                throw new ArgumentNullException(nameof(routes));
            }
            authorization = authorization ?? new IDashboardAuthorizationFilter[] { };
            app.Map(new PathString(pathMatch), x => x.Use <AspNetCoreFileManagerMiddlewareOwin <T> >(options, authorization, routes));
#endif
            return(app);
        }
        public void Configuration(Owin.IAppBuilder app)
        {
            // Branch the pipeline here for requests that start with "/signalr"
            app.Map("/signalr", map =>
            {
                // Setup the CORS middleware to run before SignalR.
                // By default this will allow all origins. You can
                // configure the set of origins and/or http verbs by
                // providing a cors options with a different policy.
                map.UseCors(CorsOptions.AllowAll);

                var hubConfiguration = new Microsoft.AspNet.SignalR.HubConfiguration
                {
                    // You can enable JSONP by uncommenting line below.
                    // JSONP requests are insecure but some older browsers (and some
                    // versions of IE) require JSONP to work cross domain
                    // EnableJSONP = true
                };

                // Run the SignalR pipeline. We're not using MapSignalR
                // since this branch already runs under the "/signalr"
                // path.
                map.RunSignalR(hubConfiguration);
            });
        }
        private static IApplicationBuilder UsePlaygroundSettingsMiddleware(
            this IApplicationBuilder applicationBuilder,
            PlaygroundOptions options)
        {
            return(applicationBuilder.Map(
                       options.Path.Add(new PathString("/settings.js")),
#if ASPNETCLASSIC
                       app => app.Use <SettingsMiddleware>(options)));
#else
                       app => app.UseMiddleware <SettingsMiddleware>(options));
#endif
        }
Beispiel #5
0
 public void Configuration(Owin.IAppBuilder app)
 {
     app.Map("/api", builder =>
     {
         builder.UseLightNode(new LightNodeOptions(AcceptVerbs.Get | AcceptVerbs.Post, new JsonNetContentFormatter())
         {
             StreamWriteOption = StreamWriteOption.BufferAndWrite,
             ParameterEnumAllowsFieldNameParse = true,
             ErrorHandlingPolicy            = ErrorHandlingPolicy.ReturnInternalServerErrorIncludeErrorDetails,
             OperationMissingHandlingPolicy = OperationMissingHandlingPolicy.ReturnErrorStatusCodeIncludeErrorDetails,
         });
     });
 }
Beispiel #6
0
        public void Configuration(Owin.IAppBuilder app)
        {
            app.Map("/signalr", map =>
            {
                map.UseCors(CorsOptions.AllowAll);
                var hubConfiguration = new HubConfiguration
                {
                    EnableJSONP = true
                };

                hubConfiguration.EnableDetailedErrors = true;
                map.RunSignalR(hubConfiguration);
            });
        }
Beispiel #7
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));
                });
            });
        }