Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ public void ConfigureServices(IServiceCollection services)
o.IgnoredResourceExtensions = new[] { "jpg", "gif", "png", "css", "js", "ico", "swf", "woff" };
o.Logging = LoggerMode.On;
o.LogWithHostname = false;
o.ActiveStatusCodes = new int[] { StatusCodes.Status404NotFound };
o.AddProvider<NullNotFoundHandlerProvider>();
});

Expand Down Expand Up @@ -151,6 +152,8 @@ If the `bufferSize` is set to `0`, the `threshold` value will be ignored, and ev

**LogWithHostname**: Set to `true` to include hostname in the log. Useful in a multisite environment with several hostnames/domains. Default is `false`

**ActiveStatusCodes**: A integerlist with the status codes that NotFoundHandler will be active on. (Ex. ```options.ActiveStatusCodes = new int[] { StatusCodes.Status404NotFound, StatusCodes.Status410Gone };```)

### Specifying ignored resources

**IgnoredResourceExtensions**
Expand Down
4 changes: 2 additions & 2 deletions src/Geta.NotFoundHandler/Core/RequestHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ public virtual void Handle(HttpContext context)
return;
}

if (context.Response.StatusCode != 404)
if (context.Response.StatusCode != StatusCodes.Status404NotFound && (_configuration.ActiveStatusCodes.Any() && !_configuration.ActiveStatusCodes.Contains(context.Response.StatusCode)))
Comment thread
wezz marked this conversation as resolved.
Outdated
{
LogDebug("Not a 404 response.", context);
LogDebug("Not a accepted statuscode.", context);
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Geta.NotFoundHandler.Core;
using Geta.NotFoundHandler.Core.Suggestions;
using Geta.NotFoundHandler.Core.Redirects;
using Microsoft.AspNetCore.Http;

namespace Geta.NotFoundHandler.Infrastructure.Configuration
{
Expand All @@ -20,6 +21,7 @@ public class NotFoundHandlerOptions
public bool UseInternalScheduler { get; set; }
public string InternalSchedulerCronInterval { get; set; } = "0 0 * * *";
public FileNotFoundMode HandlerMode { get; set; } = FileNotFoundMode.On;
public int[] ActiveStatusCodes { get; set; } = new int[] { StatusCodes.Status404NotFound };
public TimeSpan RegexTimeout { get; set; } = TimeSpan.FromMilliseconds(100);

public string[] IgnoredResourceExtensions { get; set; } =
Expand Down
Loading