Standardizing middleware to use configureOptions lambda

This commit is contained in:
John Luo 2015-12-22 20:42:09 -08:00
parent f3f7027438
commit 6d202b0fdf
1 changed files with 9 additions and 24 deletions

View File

@ -12,7 +12,7 @@ namespace Microsoft.AspNet.Builder
/// Adds middleware for interacting with the IIS HttpPlatformHandler reverse proxy module.
/// This will handle forwarded Windows Authentication, request scheme, remote IPs, etc..
/// </summary>
/// <param name="builder"></param>
/// <param name="app"></param>
/// <returns></returns>
public static IApplicationBuilder UseIISPlatformHandler(this IApplicationBuilder app)
{
@ -21,34 +21,15 @@ namespace Microsoft.AspNet.Builder
throw new ArgumentNullException(nameof(app));
}
return app.UseMiddleware<IISPlatformHandlerMiddleware>(new IISPlatformHandlerOptions());
return app.UseIISPlatformHandler(options => { });
}
/// <summary>
/// Adds middleware for interacting with the IIS HttpPlatformHandler reverse proxy module.
/// This will handle forwarded Windows Authentication, request scheme, remote IPs, etc..
/// </summary>
/// <param name="builder"></param>
/// <returns></returns>
public static IApplicationBuilder UseIISPlatformHandler(this IApplicationBuilder app, IISPlatformHandlerOptions options)
{
if (app == null)
{
throw new ArgumentNullException(nameof(app));
}
if (options == null)
{
throw new ArgumentNullException(nameof(options));
}
return app.UseMiddleware<IISPlatformHandlerMiddleware>(options);
}
/// <summary>
/// Adds middleware for interacting with the IIS HttpPlatformHandler reverse proxy module.
/// This will handle forwarded Windows Authentication, request scheme, remote IPs, etc..
/// </summary>
/// <param name="builder"></param>
/// <param name="app"></param>
/// <param name="configureOptions"></param>
/// <returns></returns>
public static IApplicationBuilder UseIISPlatformHandler(this IApplicationBuilder app, Action<IISPlatformHandlerOptions> configureOptions)
{
@ -56,6 +37,10 @@ namespace Microsoft.AspNet.Builder
{
throw new ArgumentNullException(nameof(app));
}
if (configureOptions == null)
{
throw new ArgumentNullException(nameof(configureOptions));
}
var options = new IISPlatformHandlerOptions();
if (configureOptions != null)
@ -63,7 +48,7 @@ namespace Microsoft.AspNet.Builder
configureOptions(options);
}
return app.UseIISPlatformHandler(options);
return app.UseMiddleware<IISPlatformHandlerMiddleware>(options);
}
}
}