diff --git a/src/Microsoft.AspNet.Diagnostics.Entity/DatabaseErrorPageExtensions.cs b/src/Microsoft.AspNet.Diagnostics.Entity/DatabaseErrorPageExtensions.cs index d4763eeb71..7204ba687b 100644 --- a/src/Microsoft.AspNet.Diagnostics.Entity/DatabaseErrorPageExtensions.cs +++ b/src/Microsoft.AspNet.Diagnostics.Entity/DatabaseErrorPageExtensions.cs @@ -61,6 +61,34 @@ namespace Microsoft.AspNet.Builder return app; } + /// + /// Captures synchronous and asynchronous database related exceptions from the pipeline that may be resolved using Entity Framework + /// migrations. When these exceptions occur an HTML response with details of possible actions to resolve the issue is generated. + /// + /// The to register the middleware with. + /// A that specifies options for the middleware. + /// The same instance so that multiple calls can be chained. + public static IApplicationBuilder UseDatabaseErrorPage(this IApplicationBuilder app, DatabaseErrorPageOptions options) + { + if (app == null) + { + throw new ArgumentNullException(nameof(app)); + } + if (options == null) + { + throw new ArgumentNullException(nameof(options)); + } + + app = app.UseMiddleware(options); + + if (options.EnableMigrationCommands) + { + app.UseMigrationsEndPoint(o => o.Path = options.MigrationsEndPointPath); + } + + return app; + } + /// /// Sets the options to display the maximum amount of information available. /// diff --git a/src/Microsoft.AspNet.Diagnostics.Entity/MigrationsEndPointExtensions.cs b/src/Microsoft.AspNet.Diagnostics.Entity/MigrationsEndPointExtensions.cs index d34aea8b43..e03fbeb057 100644 --- a/src/Microsoft.AspNet.Diagnostics.Entity/MigrationsEndPointExtensions.cs +++ b/src/Microsoft.AspNet.Diagnostics.Entity/MigrationsEndPointExtensions.cs @@ -20,6 +20,11 @@ namespace Microsoft.AspNet.Builder /// The same instance so that multiple calls can be chained. public static IApplicationBuilder UseMigrationsEndPoint(this IApplicationBuilder app) { + if (app == null) + { + throw new ArgumentNullException(nameof(app)); + } + return app.UseMigrationsEndPoint(options => { }); } @@ -45,5 +50,25 @@ namespace Microsoft.AspNet.Builder return app.UseMiddleware(options); } + + /// + /// Processes requests to execute migrations operations. The middleware will listen for requests to the path configured in . + /// + /// The to register the middleware with. + /// An action to set the options for the middleware. + /// The same instance so that multiple calls can be chained. + public static IApplicationBuilder UseMigrationsEndPoint(this IApplicationBuilder app, MigrationsEndPointOptions options) + { + if (app == null) + { + throw new ArgumentNullException(nameof(app)); + } + if (options == null) + { + throw new ArgumentNullException(nameof(options)); + } + + return app.UseMiddleware(options); + } } } diff --git a/src/Microsoft.AspNet.Diagnostics/DeveloperExceptionPage/DeveloperExceptionPageExtensions.cs b/src/Microsoft.AspNet.Diagnostics/DeveloperExceptionPage/DeveloperExceptionPageExtensions.cs index f895173ad6..951dbc7610 100644 --- a/src/Microsoft.AspNet.Diagnostics/DeveloperExceptionPage/DeveloperExceptionPageExtensions.cs +++ b/src/Microsoft.AspNet.Diagnostics/DeveloperExceptionPage/DeveloperExceptionPageExtensions.cs @@ -50,5 +50,28 @@ namespace Microsoft.AspNet.Builder configureOptions(options); return app.UseMiddleware(options); } + + /// + /// Captures synchronous and asynchronous instances from the pipeline and generates HTML error responses. + /// + /// The . + /// A that specifies options for the middleware. + /// A reference to the after the operation has completed. + public static IApplicationBuilder UseDeveloperExceptionPage( + this IApplicationBuilder app, + DeveloperExceptionPageOptions options) + { + if (app == null) + { + throw new ArgumentNullException(nameof(app)); + } + + if (options == null) + { + throw new ArgumentNullException(nameof(options)); + } + + return app.UseMiddleware(options); + } } } diff --git a/src/Microsoft.AspNet.Diagnostics/ExceptionHandler/ExceptionHandlerExtensions.cs b/src/Microsoft.AspNet.Diagnostics/ExceptionHandler/ExceptionHandlerExtensions.cs index f852fe8ad6..d92e9bc47a 100644 --- a/src/Microsoft.AspNet.Diagnostics/ExceptionHandler/ExceptionHandlerExtensions.cs +++ b/src/Microsoft.AspNet.Diagnostics/ExceptionHandler/ExceptionHandlerExtensions.cs @@ -74,5 +74,26 @@ namespace Microsoft.AspNet.Builder return app.UseMiddleware(options); } + + /// + /// Adds a middleware to the pipeline that will catch exceptions, log them, and re-execute the request in an alternate pipeline. + /// The request will not be re-executed if the response has already started. + /// + /// + /// + /// + public static IApplicationBuilder UseExceptionHandler(this IApplicationBuilder app, ExceptionHandlerOptions 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 diff --git a/src/Microsoft.AspNet.Diagnostics/RuntimeInfo/RuntimeInfoExtensions.cs b/src/Microsoft.AspNet.Diagnostics/RuntimeInfo/RuntimeInfoExtensions.cs index 524c42f6cf..8c49249547 100644 --- a/src/Microsoft.AspNet.Diagnostics/RuntimeInfo/RuntimeInfoExtensions.cs +++ b/src/Microsoft.AspNet.Diagnostics/RuntimeInfo/RuntimeInfoExtensions.cs @@ -50,5 +50,24 @@ namespace Microsoft.AspNet.Builder return app.Use(next => new RuntimeInfoMiddleware(next, options, libraryManager, runtimeEnvironment).Invoke); } + + public static IApplicationBuilder UseRuntimeInfoPage( + this IApplicationBuilder app, + RuntimeInfoPageOptions options) + { + if (app == null) + { + throw new ArgumentNullException(nameof(app)); + } + if (options == null) + { + throw new ArgumentNullException(nameof(options)); + } + + var libraryManager = app.ApplicationServices.GetService(typeof(ILibraryManager)) as ILibraryManager; + var runtimeEnvironment = app.ApplicationServices.GetService(typeof(IRuntimeEnvironment)) as IRuntimeEnvironment; + + return app.Use(next => new RuntimeInfoMiddleware(next, options, libraryManager, runtimeEnvironment).Invoke); + } } } \ No newline at end of file diff --git a/src/Microsoft.AspNet.Diagnostics/StatusCodePage/StatusCodePagesExtensions.cs b/src/Microsoft.AspNet.Diagnostics/StatusCodePage/StatusCodePagesExtensions.cs index 176116fedc..4175984276 100644 --- a/src/Microsoft.AspNet.Diagnostics/StatusCodePage/StatusCodePagesExtensions.cs +++ b/src/Microsoft.AspNet.Diagnostics/StatusCodePage/StatusCodePagesExtensions.cs @@ -36,6 +36,27 @@ namespace Microsoft.AspNet.Builder return app.UseMiddleware(options); } + /// + /// Adds a StatusCodePages middleware with the given options that checks for responses with status codes + /// between 400 and 599 that do not have a body. + /// + /// + /// + /// + public static IApplicationBuilder UseStatusCodePages(this IApplicationBuilder app, StatusCodePagesOptions options) + { + if (app == null) + { + throw new ArgumentNullException(nameof(app)); + } + if (options == null) + { + throw new ArgumentNullException(nameof(options)); + } + + return app.UseMiddleware(options); + } + /// /// Adds a StatusCodePages middleware with a default response handler that checks for responses with status codes /// between 400 and 599 that do not have a body. diff --git a/src/Microsoft.AspNet.Diagnostics/WelcomePage/WelcomePageExtensions.cs b/src/Microsoft.AspNet.Diagnostics/WelcomePage/WelcomePageExtensions.cs index 478f342b3f..255d6d7002 100644 --- a/src/Microsoft.AspNet.Diagnostics/WelcomePage/WelcomePageExtensions.cs +++ b/src/Microsoft.AspNet.Diagnostics/WelcomePage/WelcomePageExtensions.cs @@ -36,6 +36,26 @@ namespace Microsoft.AspNet.Builder return app.UseMiddleware(options); } + /// + /// Adds the WelcomePageMiddleware to the pipeline with the given options. + /// + /// + /// + /// + public static IApplicationBuilder UseWelcomePage(this IApplicationBuilder app, WelcomePageOptions options) + { + if (app == null) + { + throw new ArgumentNullException(nameof(app)); + } + if (options == null) + { + throw new ArgumentNullException(nameof(options)); + } + + return app.UseMiddleware(options); + } + /// /// Adds the WelcomePageMiddleware to the pipeline with the given path. ///