Skip to content

Commit b591bd7

Browse files
committed
Expose includeStaticFiles configuration option to MapTopicErrors()
The `MapTopicErrors()` extension method is one way to configure routing to the `ErrorController`. It isn't the _only_ approach, but it is the one that provides easiest access to the main variables that implementers are likely to want to change, such as the base URL. This is now extended to optionally accept an `includeStaticFiles` parameter, which maps to the parameter of a corresponding name on the `Http` action itself (83f4691). If set to `false`, static files won't return a custom error page—or, rather, will get one, but it will only contain a very lightweight, canned message. This satisfies the configuration requirements of Feature #101.
1 parent 83f4691 commit b591bd7

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

OnTopic.AspNetCore.Mvc/ServiceCollectionExtensions.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,11 +221,18 @@ public static void MapImplicitAreaControllerRoute(this IEndpointRouteBuilder rou
221221
/// StatusCodePagesExtensions.UseStatusCodePages(IApplicationBuilder)"/>, by providing a route for capturing the <c>
222222
/// errorCode</c>.
223223
/// </remarks>
224-
public static ControllerActionEndpointConventionBuilder MapTopicErrors(this IEndpointRouteBuilder routes, string rootTopic = "Error") =>
224+
/// <param name="routes">The <see cref="IEndpointRouteBuilder"/> this route is being added to.</param>
225+
/// <param name="rootTopic">The name of the root topic that the route should be mapped to. Defaults to <c>Error</c>.</param>
226+
/// <param name="includeStaticFiles">Determines if static resources should be covered. Defaults to <c>true</c>.</param>
227+
public static ControllerActionEndpointConventionBuilder MapTopicErrors(
228+
this IEndpointRouteBuilder routes,
229+
string rootTopic = "Error",
230+
bool includeStaticFiles = true
231+
) =>
225232
routes.MapControllerRoute(
226233
name: "TopicError",
227234
pattern: $"{rootTopic}/{{id:int}}/",
228-
defaults: new { controller = "Error", action = "Http", rootTopic }
235+
defaults: new { controller = "Error", action = "Http", rootTopic, includeStaticFiles }
229236
);
230237

231238
/*==========================================================================================================================

0 commit comments

Comments
 (0)