Adding back middleware initialization with options instance.
This commit is contained in:
parent
6f9b827e5b
commit
7624d97114
|
|
@ -65,5 +65,25 @@ namespace Microsoft.AspNet.Builder
|
|||
|
||||
return app.UseMiddleware<DefaultFilesMiddleware>(options);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enables default file mapping with the given options
|
||||
/// </summary>
|
||||
/// <param name="app"></param>
|
||||
/// <param name="options"></param>
|
||||
/// <returns></returns>
|
||||
public static IApplicationBuilder UseDefaultFiles(this IApplicationBuilder app, DefaultFilesOptions options)
|
||||
{
|
||||
if (app == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(app));
|
||||
}
|
||||
if (options == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(options));
|
||||
}
|
||||
|
||||
return app.UseMiddleware<DefaultFilesMiddleware>(options);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -65,5 +65,25 @@ namespace Microsoft.AspNet.Builder
|
|||
|
||||
return app.UseMiddleware<DirectoryBrowserMiddleware>(options);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enable directory browsing with the given options
|
||||
/// </summary>
|
||||
/// <param name="app"></param>
|
||||
/// <param name="options"></param>
|
||||
/// <returns></returns>
|
||||
public static IApplicationBuilder UseDirectoryBrowser(this IApplicationBuilder app, DirectoryBrowserOptions options)
|
||||
{
|
||||
if (app == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(app));
|
||||
}
|
||||
if (options == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(options));
|
||||
}
|
||||
|
||||
return app.UseMiddleware<DirectoryBrowserMiddleware>(options);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -97,5 +97,35 @@ namespace Microsoft.AspNet.Builder
|
|||
|
||||
return app.UseStaticFiles(options => { options = fileServerOptions.StaticFileOptions; });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enable all static file middleware with the given options
|
||||
/// </summary>
|
||||
/// <param name="app"></param>
|
||||
/// <param name="options"></param>
|
||||
/// <returns></returns>
|
||||
public static IApplicationBuilder UseFileServer(this IApplicationBuilder app, FileServerOptions options)
|
||||
{
|
||||
if (app == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(app));
|
||||
}
|
||||
if (options == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(options));
|
||||
}
|
||||
|
||||
if (options.EnableDefaultFiles)
|
||||
{
|
||||
app = app.UseDefaultFiles(options.DefaultFilesOptions);
|
||||
}
|
||||
|
||||
if (options.EnableDirectoryBrowsing)
|
||||
{
|
||||
app = app.UseDirectoryBrowser(options.DirectoryBrowserOptions);
|
||||
}
|
||||
|
||||
return app.UseStaticFiles(options.StaticFileOptions);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -65,5 +65,25 @@ namespace Microsoft.AspNet.Builder
|
|||
|
||||
return app.UseMiddleware<StaticFileMiddleware>(options);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enables static file serving with the given options
|
||||
/// </summary>
|
||||
/// <param name="app"></param>
|
||||
/// <param name="options"></param>
|
||||
/// <returns></returns>
|
||||
public static IApplicationBuilder UseStaticFiles(this IApplicationBuilder app, StaticFileOptions options)
|
||||
{
|
||||
if (app == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(app));
|
||||
}
|
||||
if (options == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(options));
|
||||
}
|
||||
|
||||
return app.UseMiddleware<StaticFileMiddleware>(options);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue