コード例 #1
0
 public static IApplicationBuilder MapAddFile(this IApplicationBuilder app, IFileserverConfig <HttpRequest> config)
 {
     app.MapWhen(c => HttpMethod.Post.Method.Equals(c.Request.Method, StringComparison.OrdinalIgnoreCase),
                 builder =>
     {
         builder.Run(async context =>
         {
             var handler = new AddFileHandler(builder.ApplicationServices.GetService(typeof(ILoggerFactory)) as ILoggerFactory, config.NewFilePipeline());
             await handler.Invoke(context);
         });
     });
     return(app);
 }
コード例 #2
0
 public static IApplicationBuilder MapAddFile(this IApplicationBuilder app, IFileserverConfig<HttpRequest> config)
 {
     app.MapWhen(c => HttpMethod.Post.Method.Equals(c.Request.Method, StringComparison.OrdinalIgnoreCase),
     builder =>
     {
         builder.Run(async context =>
         {
             var handler = new AddFileHandler(builder.ApplicationServices.GetService(typeof(ILoggerFactory)) as ILoggerFactory, config.NewFilePipeline());
             await handler.Invoke(context);
         });
     });
     return app;
 }
コード例 #3
0
 public static IApplicationBuilder MapDelFile(this IApplicationBuilder app, IFileserverConfig <HttpRequest> config)
 {
     // Branch requests to {path}/info or {path}?info - returns only file metadata
     app.MapWhen(c => (HttpMethod.Delete.Method.Equals(c.Request.Method, StringComparison.OrdinalIgnoreCase) &&
                       c.Request.Path.HasValue),
                 builder =>
     {
         builder.Run(async context =>
         {
             var handler = new DeleteFileHandler(builder.ApplicationServices.GetService(typeof(ILoggerFactory)) as ILoggerFactory, config.FileStorage());
             await handler.Invoke(context);
         });
     });
     return(app);
 }
コード例 #4
0
 public static IApplicationBuilder MapDelFile(this IApplicationBuilder app, IFileserverConfig<HttpRequest> config)
 {
     // Branch requests to {path}/info or {path}?info - returns only file metadata
     app.MapWhen(c => (HttpMethod.Delete.Method.Equals(c.Request.Method, StringComparison.OrdinalIgnoreCase) &&
                         c.Request.Path.HasValue),
     builder =>
     {
         builder.Run(async context =>
         {
             var handler = new DeleteFileHandler(builder.ApplicationServices.GetService(typeof(ILoggerFactory)) as ILoggerFactory, config.FileStorage());
             await handler.Invoke(context);
         });
     });
     return app;
 }
コード例 #5
0
        public static IApplicationBuilder UseFileserver(this IApplicationBuilder app, IFileserverConfig<HttpRequest> config)
        {
            if (!string.IsNullOrEmpty(config.Path) && config.Path != "/")
            {
                app
                    .Map(config.Path, builder =>
                    {
                        builder
                            .MapDelFile(config)
                            .MapAddFile(config);
                    });
            }
            else
            {
                app.MapDelFile(config);
                app.MapAddFile(config);
            }

            return app;
        }
コード例 #6
0
        public static IAppBuilder UseFileserver(this IAppBuilder app, IFileserverConfig<IOwinRequest> config)
        {
            if (!string.IsNullOrEmpty(config.Path) && config.Path != "/")
            {
                app
                    .Map(config.Path, builder =>
                    {
                        builder
                            .Use<DeleteFileMiddleware>(builder.GetLoggerFactory(), config.FileStorage())
                            .Use<AddFileMiddleware>(builder.GetLoggerFactory(), config.NewFilePipeline());
                    });
            }
            else
            {
                app
                    .Use<DeleteFileMiddleware>(app.GetLoggerFactory(), config.FileStorage())
                    .Use<AddFileMiddleware>(app.GetLoggerFactory(), config.NewFilePipeline());
            }

            return app;
        }
コード例 #7
0
        public static IAppBuilder UseFileserver(this IAppBuilder app, IFileserverConfig <IOwinRequest> config)
        {
            if (!string.IsNullOrEmpty(config.Path) && config.Path != "/")
            {
                app
                .Map(config.Path, builder =>
                {
                    builder
                    .Use <DeleteFileMiddleware>(builder.GetLoggerFactory(), config.FileStorage())
                    .Use <AddFileMiddleware>(builder.GetLoggerFactory(), config.NewFilePipeline());
                });
            }
            else
            {
                app
                .Use <DeleteFileMiddleware>(app.GetLoggerFactory(), config.FileStorage())
                .Use <AddFileMiddleware>(app.GetLoggerFactory(), config.NewFilePipeline());
            }

            return(app);
        }
コード例 #8
0
        public static IApplicationBuilder UseFileserver(this IApplicationBuilder app,
                                                        IFileserverConfig <HttpRequest> config)
        {
            if (!string.IsNullOrEmpty(config.Path) && config.Path != "/")
            {
                app
                .Map(config.Path, builder =>
                {
                    builder
                    .MapDelFile(config)
                    .MapAddFile(config);
                });
            }
            else
            {
                app.MapDelFile(config);
                app.MapAddFile(config);
            }

            return(app);
        }