From 887203781255edd2501db9ccd62b8dc74ab95855 Mon Sep 17 00:00:00 2001 From: John Luo Date: Wed, 23 Dec 2015 15:43:52 -0800 Subject: [PATCH] Adding back middleware initialization with options instance --- .../WebSocketMiddlewareExtensions.cs | 30 ++++++++++++++----- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/src/Microsoft.AspNet.WebSockets.Server/WebSocketMiddlewareExtensions.cs b/src/Microsoft.AspNet.WebSockets.Server/WebSocketMiddlewareExtensions.cs index b22a09ad7f..a4cbdc7f61 100644 --- a/src/Microsoft.AspNet.WebSockets.Server/WebSocketMiddlewareExtensions.cs +++ b/src/Microsoft.AspNet.WebSockets.Server/WebSocketMiddlewareExtensions.cs @@ -8,21 +8,21 @@ namespace Microsoft.AspNet.Builder { public static class WebSocketMiddlewareExtensions { - public static IApplicationBuilder UseWebSockets(this IApplicationBuilder builder) + public static IApplicationBuilder UseWebSockets(this IApplicationBuilder app) { - if (builder == null) + if (app == null) { - throw new ArgumentNullException(nameof(builder)); + throw new ArgumentNullException(nameof(app)); } - return builder.UseWebSockets(options => { }); + return app.UseWebSockets(options => { }); } - public static IApplicationBuilder UseWebSockets(this IApplicationBuilder builder, Action configureOptions) + public static IApplicationBuilder UseWebSockets(this IApplicationBuilder app, Action configureOptions) { - if (builder == null) + if (app == null) { - throw new ArgumentNullException(nameof(builder)); + throw new ArgumentNullException(nameof(app)); } if (configureOptions == null) { @@ -32,7 +32,21 @@ namespace Microsoft.AspNet.Builder var options = new WebSocketOptions(); configureOptions(options); - return builder.Use(next => new WebSocketMiddleware(next, options).Invoke); + return app.UseMiddleware(options); + } + + public static IApplicationBuilder UseWebSockets(this IApplicationBuilder app, WebSocketOptions options) + { + if (app == null) + { + throw new ArgumentNullException(nameof(app)); + } + if (options == null) + { + throw new ArgumentNullException(nameof(options)); + } + + return app.UseMiddleware(options); } } } \ No newline at end of file