Skip to content

Commit 0230b6c

Browse files
committed
docs: comments for DefaultActionFilter and DefaultTypeFilter
1 parent a7618f6 commit 0230b6c

File tree

4 files changed

+50
-28
lines changed

4 files changed

+50
-28
lines changed

src/JsonApiDotNetCore/Middleware/JsonApiExceptionFilter.cs renamed to src/JsonApiDotNetCore/Middleware/DefaultExceptionFilter.cs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,13 @@
1-
using System;
2-
using JsonApiDotNetCore.Internal;
1+
using JsonApiDotNetCore.Internal;
32
using Microsoft.AspNetCore.Mvc;
43
using Microsoft.AspNetCore.Mvc.Filters;
54
using Microsoft.Extensions.Logging;
65

76
namespace JsonApiDotNetCore.Middleware
87
{
9-
public interface IJsonApiExceptionFilterProvider
10-
{
11-
Type Get();
12-
}
13-
14-
public class JsonApiExceptionFilterProvider : IJsonApiExceptionFilterProvider
15-
{
16-
public Type Get() => typeof(DefaultExceptionFilter);
17-
}
18-
8+
/// <summary>
9+
/// Global exception filter that wraps any thrown error with a JsonApiException.
10+
/// </summary>
1911
public class DefaultExceptionFilter : ActionFilterAttribute, IExceptionFilter
2012
{
2113
private readonly ILogger _logger;

src/JsonApiDotNetCore/Middleware/TypeMatchFilter.cs renamed to src/JsonApiDotNetCore/Middleware/DefaultTypeMatchFilter.cs

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Linq;
33
using JsonApiDotNetCore.Internal;
44
using JsonApiDotNetCore.Internal.Contracts;
@@ -7,28 +7,18 @@
77

88
namespace JsonApiDotNetCore.Middleware
99
{
10-
public interface IJsonApiTypeMatchFilterProvider
11-
{
12-
Type Get();
13-
}
14-
15-
public class JsonApiTypeMatchFilterProvider : IJsonApiTypeMatchFilterProvider
16-
{
17-
public Type Get() => typeof(TypeMatchFilter);
18-
}
19-
20-
public class TypeMatchFilter : IActionFilter
10+
/// <summary>
11+
/// Action filter used to verify the incoming type matches the target type, else return a 409
12+
/// </summary>
13+
public class DefaultTypeMatchFilter : IActionFilter
2114
{
2215
private readonly IContextEntityProvider _provider;
2316

24-
public TypeMatchFilter(IContextEntityProvider provider)
17+
public DefaultTypeMatchFilter(IContextEntityProvider provider)
2518
{
2619
_provider = provider;
2720
}
2821

29-
/// <summary>
30-
/// Used to verify the incoming type matches the target type, else return a 409
31-
/// </summary>
3222
public void OnActionExecuting(ActionExecutingContext context)
3323
{
3424
var request = context.HttpContext.Request;
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using System;
2+
3+
namespace JsonApiDotNetCore.Middleware
4+
{
5+
/// <summary>
6+
/// Provides the type of the global exception filter that is configured in MVC during startup.
7+
/// This can be overridden to let JADNC use your own exception filter. The default exception filter used
8+
/// is <see cref="DefaultExceptionFilter"/>
9+
/// </summary>
10+
public interface IJsonApiExceptionFilterProvider
11+
{
12+
Type Get();
13+
}
14+
15+
/// <inheritdoc/>
16+
public class JsonApiExceptionFilterProvider : IJsonApiExceptionFilterProvider
17+
{
18+
public Type Get() => typeof(DefaultExceptionFilter);
19+
}
20+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using System;
2+
3+
namespace JsonApiDotNetCore.Middleware
4+
{
5+
/// <summary>
6+
/// Provides the type of the global action filter that is configured in MVC during startup.
7+
/// This can be overridden to let JADNC use your own exception filter. The default exception filter used
8+
/// is <see cref="DefaultTypeMatchFilter"/>
9+
/// </summary>
10+
public interface IJsonApiTypeMatchFilterProvider
11+
{
12+
Type Get();
13+
}
14+
15+
/// <inheritdoc/>
16+
public class JsonApiTypeMatchFilterProvider : IJsonApiTypeMatchFilterProvider
17+
{
18+
public Type Get() => typeof(DefaultTypeMatchFilter);
19+
}
20+
}

0 commit comments

Comments
 (0)