@@ -18,22 +18,38 @@ public static class IServiceCollectionExtensions
18
18
public static void AddJsonApi < TContext > ( this IServiceCollection services )
19
19
where TContext : DbContext
20
20
{
21
- _addInternals < TContext > ( services , new JsonApiOptions ( ) ) ;
21
+ var mvcBuilder = services . AddMvc ( ) ;
22
+ AddInternals < TContext > ( services , new JsonApiOptions ( ) , mvcBuilder ) ;
22
23
}
23
24
24
25
public static void AddJsonApi < TContext > ( this IServiceCollection services , Action < JsonApiOptions > options )
25
26
where TContext : DbContext
26
27
{
27
28
var config = new JsonApiOptions ( ) ;
29
+
28
30
options ( config ) ;
29
- _addInternals < TContext > ( services , config ) ;
31
+
32
+ var mvcBuilder = services . AddMvc ( ) ;
33
+ AddInternals < TContext > ( services , config , mvcBuilder ) ;
30
34
}
31
35
32
- private static void _addInternals < TContext > ( IServiceCollection services , JsonApiOptions jsonApiOptions )
33
- where TContext : DbContext
36
+ public static void AddJsonApi < TContext > ( this IServiceCollection services ,
37
+ Action < JsonApiOptions > options ,
38
+ IMvcBuilder mvcBuilder ) where TContext : DbContext
39
+ {
40
+ var config = new JsonApiOptions ( ) ;
41
+
42
+ options ( config ) ;
43
+
44
+ AddInternals < TContext > ( services , config , mvcBuilder ) ;
45
+ }
46
+
47
+ private static void AddInternals < TContext > ( IServiceCollection services ,
48
+ JsonApiOptions jsonApiOptions ,
49
+ IMvcBuilder mvcBuilder ) where TContext : DbContext
34
50
{
35
51
services . AddJsonApiInternals < TContext > ( jsonApiOptions ) ;
36
- services . AddMvc ( )
52
+ mvcBuilder
37
53
. AddMvcOptions ( opt => {
38
54
opt . Filters . Add ( typeof ( JsonApiExceptionFilter ) ) ;
39
55
opt . SerializeAsJsonApi ( jsonApiOptions ) ;
0 commit comments