Skip to content

Commit 64ce4c1

Browse files
committed
Change to use int options instead of boolean
1 parent 8f784af commit 64ce4c1

3 files changed

Lines changed: 5 additions & 4 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ If the `bufferSize` is set to `0`, the `threshold` value will be ignored, and ev
152152

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

155-
**Handle410**: Set to `true` to handle redirect for expired pages in Optimizely.
155+
**ActiveStatusCodes**: A integerlist with the status codes that NotFoundHandler will be active on. (Ex. ```options.ActiveStatusCodes = new int[] { StatusCodes.Status404NotFound, StatusCodes.Status410Gone };```)
156156

157157
### Specifying ignored resources
158158

src/Geta.NotFoundHandler/Core/RequestHandler.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ public virtual void Handle(HttpContext context)
4444
return;
4545
}
4646

47-
if (context.Response.StatusCode != 404 && (_configuration.Handle410 && context.Response.StatusCode != 410))
47+
if (context.Response.StatusCode != StatusCodes.Status404NotFound && (_configuration.ActiveStatusCodes.Any() && !_configuration.ActiveStatusCodes.Contains(context.Response.StatusCode)))
4848
{
49-
LogDebug("Not a 404 or 410 response.", context);
49+
LogDebug("Not a accepted statuscode.", context);
5050
return;
5151
}
5252

src/Geta.NotFoundHandler/Infrastructure/Configuration/NotFoundHandlerOptions.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using Geta.NotFoundHandler.Core;
77
using Geta.NotFoundHandler.Core.Suggestions;
88
using Geta.NotFoundHandler.Core.Redirects;
9+
using Microsoft.AspNetCore.Http;
910

1011
namespace Geta.NotFoundHandler.Infrastructure.Configuration
1112
{
@@ -20,7 +21,7 @@ public class NotFoundHandlerOptions
2021
public bool UseInternalScheduler { get; set; }
2122
public string InternalSchedulerCronInterval { get; set; } = "0 0 * * *";
2223
public FileNotFoundMode HandlerMode { get; set; } = FileNotFoundMode.On;
23-
public bool Handle410 { get; set; } = false;
24+
public int[] ActiveStatusCodes { get; set; } = new int[] { StatusCodes.Status404NotFound };
2425
public TimeSpan RegexTimeout { get; set; } = TimeSpan.FromMilliseconds(100);
2526

2627
public string[] IgnoredResourceExtensions { get; set; } =

0 commit comments

Comments
 (0)