File tree 2 files changed +11
-4
lines changed
2 files changed +11
-4
lines changed Original file line number Diff line number Diff line change 7
7
using Microsoft . AspNetCore . Mvc ;
8
8
using Microsoft . AspNetCore . Mvc . ViewFeatures ;
9
9
using Microsoft . Extensions . DependencyInjection ;
10
+ using Microsoft . Extensions . Options ;
10
11
11
12
namespace InertiaNetCore . Extensions ;
12
13
@@ -40,21 +41,24 @@ public static IApplicationBuilder UseInertia(this IApplicationBuilder app)
40
41
}
41
42
42
43
public static IServiceCollection AddInertia ( this IServiceCollection services ,
43
- Action < InertiaOptions > ? options = null , bool flashEnabled = true )
44
+ Action < InertiaOptions > ? options = null )
44
45
{
45
46
services . AddHttpContextAccessor ( ) ;
46
47
services . AddHttpClient ( ) ;
47
48
48
49
services . AddSingleton < SsrGateway > ( ) ;
49
50
services . AddSingleton < ResponseFactory > ( ) ;
50
51
51
- if ( flashEnabled )
52
- services . AddSession ( ) ;
53
52
54
53
services . Configure < MvcOptions > ( mvcOptions => { mvcOptions . Filters . Add < InertiaActionFilter > ( ) ; } ) ;
55
54
56
- if ( options != null )
55
+ if ( options != null )
56
+ {
57
57
services . Configure ( options ) ;
58
+ }
59
+
60
+ var opts = services . BuildServiceProvider ( ) . GetRequiredService < IOptions < InertiaOptions > > ( ) . Value ;
61
+ services . AddSession ( opts . ConfigureSession ) ;
58
62
59
63
return services ;
60
64
}
Original file line number Diff line number Diff line change 1
1
using System . Text . Json ;
2
2
using System . Text . Json . Serialization ;
3
+ using Microsoft . AspNetCore . Builder ;
3
4
4
5
namespace InertiaNetCore . Models ;
5
6
@@ -10,6 +11,8 @@ public class InertiaOptions
10
11
public bool SsrEnabled { get ; set ; } = false ;
11
12
public string SsrUrl { get ; set ; } = "http://127.0.0.1:13714/render" ;
12
13
14
+ public Action < SessionOptions > ConfigureSession { get ; set ; } = _ => { } ;
15
+
13
16
private static JsonSerializerOptions DefaultJsonSerializerOptions { get ; } = new ( )
14
17
{
15
18
PropertyNamingPolicy = JsonNamingPolicy . CamelCase ,
You can’t perform that action at this time.
0 commit comments