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;
        }
示例#2
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);
        }
 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;
 }
 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);
 }