9
9
10
10
namespace InertiaNetCore ;
11
11
12
- public class Response ( string component , InertiaProps props , string ? version , InertiaOptions options )
12
+ public class Response ( string component , InertiaProps props , string ? version , InertiaOptions options , bool ? encryptHistory , bool clearHistory )
13
13
: IActionResult
14
14
{
15
15
private IDictionary < string , object > ? _viewData ;
16
+ private readonly InertiaOptions _options = options ;
16
17
17
18
public async Task ExecuteResultAsync ( ActionContext context )
18
19
{
@@ -23,7 +24,9 @@ public async Task ExecuteResultAsync(ActionContext context)
23
24
Url = context . HttpContext . RequestedUri ( ) ,
24
25
Props = await GetFinalProps ( context ) ,
25
26
DeferredProps = GetDeferredProps ( context ) ,
26
- MergeProps = GetMergeProps ( context )
27
+ MergeProps = GetMergeProps ( context ) ,
28
+ ClearHistory = clearHistory ,
29
+ EncryptHistory = encryptHistory ?? options . EncryptHistory
27
30
} ;
28
31
29
32
if ( ! context . HttpContext . IsInertiaRequest ( ) )
@@ -39,15 +42,15 @@ public async Task ExecuteResultAsync(ActionContext context)
39
42
viewData [ key ] = value ;
40
43
}
41
44
42
- await new ViewResult { ViewName = options . RootView , ViewData = viewData } . ExecuteResultAsync ( context ) ;
45
+ await new ViewResult { ViewName = _options . RootView , ViewData = viewData } . ExecuteResultAsync ( context ) ;
43
46
}
44
47
else
45
48
{
46
49
context . HttpContext . Response . Headers . Append ( "X-Inertia" , "true" ) ;
47
50
context . HttpContext . Response . Headers . Append ( "Vary" , "Accept" ) ;
48
51
context . HttpContext . Response . StatusCode = 200 ;
49
52
50
- var jsonResult = new JsonResult ( page , options . JsonSerializerOptions ) ;
53
+ var jsonResult = new JsonResult ( page , _options . JsonSerializerOptions ) ;
51
54
await jsonResult . ExecuteResultAsync ( context ) ;
52
55
}
53
56
}
@@ -89,7 +92,7 @@ private Dictionary<string, List<string>> GetDeferredProps(ActionContext context)
89
92
}
90
93
91
94
// apply json serialization options to dictionary keys before grouping them
92
- var jsonOptions = options . JsonSerializerOptions as JsonSerializerOptions ;
95
+ var jsonOptions = _options . JsonSerializerOptions as JsonSerializerOptions ;
93
96
tmp = JsonSerializer . Deserialize < Dictionary < string , string > > ( JsonSerializer . Serialize ( tmp , jsonOptions ) , jsonOptions ) ;
94
97
95
98
return tmp !
@@ -113,7 +116,7 @@ private List<string> GetMergeProps(ActionContext context)
113
116
}
114
117
115
118
// apply json serialization options to dictionary keys before grouping them
116
- var jsonOptions = options . JsonSerializerOptions as JsonSerializerOptions ;
119
+ var jsonOptions = _options . JsonSerializerOptions as JsonSerializerOptions ;
117
120
tmp = JsonSerializer . Deserialize < Dictionary < string , string > > ( JsonSerializer . Serialize ( tmp , jsonOptions ) , jsonOptions ) ;
118
121
119
122
return tmp ! . Select ( prop => prop . Key ) . ToList ( ) ;
0 commit comments