@@ -24,16 +24,22 @@ public Response(string component, object props, string rootView, string? version
24
24
public async Task ExecuteResultAsync ( ActionContext context )
25
25
{
26
26
SetContext ( context ) ;
27
+ ProcessResponse ( ) ;
27
28
29
+ await GetResult ( ) . ExecuteResultAsync ( _context ! ) ;
30
+ }
31
+
32
+ protected internal void ProcessResponse ( )
33
+ {
28
34
var page = new Page
29
35
{
30
36
Component = _component ,
31
37
Version = _version ,
32
38
Url = _context ! . RequestedUri ( )
33
39
} ;
34
40
35
- var partial = context . GetPartialData ( ) ;
36
- if ( partial . Any ( ) && context . IsInertiaPartialComponent ( _component ) )
41
+ var partial = _context ! . GetPartialData ( ) ;
42
+ if ( partial . Any ( ) && _context ! . IsInertiaPartialComponent ( _component ) )
37
43
{
38
44
var only = _props . Only ( partial ) ;
39
45
var partialProps = only . ToDictionary ( o => o . ToCamelCase ( ) , o =>
@@ -48,18 +54,16 @@ public async Task ExecuteResultAsync(ActionContext context)
48
54
page . Props = props ;
49
55
}
50
56
51
- var shared = context . HttpContext . Features . Get < InertiaSharedData > ( ) ;
57
+ var shared = _context ! . HttpContext . Features . Get < InertiaSharedData > ( ) ;
52
58
if ( shared != null )
53
59
page . Props = shared . GetMerged ( page . Props ) ;
54
60
55
61
page . Props [ "errors" ] = GetErrors ( ) ;
56
62
57
63
SetPage ( page ) ;
58
-
59
- await GetResult ( ) . ExecuteResultAsync ( _context ! ) ;
60
64
}
61
65
62
- private JsonResult GetJson ( )
66
+ protected internal JsonResult GetJson ( )
63
67
{
64
68
_context ! . HttpContext . Response . Headers . Add ( "X-Inertia" , "true" ) ;
65
69
_context ! . HttpContext . Response . Headers . Add ( "Vary" , "Accept" ) ;
@@ -87,7 +91,7 @@ private ViewResult GetView()
87
91
return new ViewResult { ViewName = _rootView , ViewData = viewData } ;
88
92
}
89
93
90
- private IActionResult GetResult ( ) => _context ! . IsInertiaRequest ( ) ? GetJson ( ) : GetView ( ) ;
94
+ protected internal IActionResult GetResult ( ) => _context ! . IsInertiaRequest ( ) ? GetJson ( ) : GetView ( ) ;
91
95
92
96
private IDictionary < string , string > GetErrors ( )
93
97
{
@@ -98,7 +102,7 @@ private IDictionary<string, string> GetErrors()
98
102
return new Dictionary < string , string > ( 0 ) ;
99
103
}
100
104
101
- private void SetContext ( ActionContext context ) => _context = context ;
105
+ protected internal void SetContext ( ActionContext context ) => _context = context ;
102
106
103
107
private void SetPage ( Page page ) => _page = page ;
104
108
0 commit comments