File tree 4 files changed +50
-28
lines changed
src/JsonApiDotNetCore/Middleware 4 files changed +50
-28
lines changed Original file line number Diff line number Diff line change 1
- using System ;
2
- using JsonApiDotNetCore . Internal ;
1
+ using JsonApiDotNetCore . Internal ;
3
2
using Microsoft . AspNetCore . Mvc ;
4
3
using Microsoft . AspNetCore . Mvc . Filters ;
5
4
using Microsoft . Extensions . Logging ;
6
5
7
6
namespace JsonApiDotNetCore . Middleware
8
7
{
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>
19
11
public class DefaultExceptionFilter : ActionFilterAttribute , IExceptionFilter
20
12
{
21
13
private readonly ILogger _logger ;
Original file line number Diff line number Diff line change 1
- using System ;
1
+ using System ;
2
2
using System . Linq ;
3
3
using JsonApiDotNetCore . Internal ;
4
4
using JsonApiDotNetCore . Internal . Contracts ;
7
7
8
8
namespace JsonApiDotNetCore . Middleware
9
9
{
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
21
14
{
22
15
private readonly IContextEntityProvider _provider ;
23
16
24
- public TypeMatchFilter ( IContextEntityProvider provider )
17
+ public DefaultTypeMatchFilter ( IContextEntityProvider provider )
25
18
{
26
19
_provider = provider ;
27
20
}
28
21
29
- /// <summary>
30
- /// Used to verify the incoming type matches the target type, else return a 409
31
- /// </summary>
32
22
public void OnActionExecuting ( ActionExecutingContext context )
33
23
{
34
24
var request = context . HttpContext . Request ;
Original file line number Diff line number Diff line change
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
+ }
Original file line number Diff line number Diff line change
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
+ }
You can’t perform that action at this time.
0 commit comments