@@ -4,6 +4,7 @@ use crate::config_manager::ConfigManager;
4
4
use crate :: decode_time_str:: decode_time_str;
5
5
use crate :: errors:: * ;
6
6
use crate :: template:: { States , Template , TemplateMap } ;
7
+ use crate :: Request ;
7
8
use chrono:: { DateTime , Utc } ;
8
9
use serde:: { Deserialize , Serialize } ;
9
10
use std:: collections:: HashMap ;
@@ -47,9 +48,10 @@ fn render_build_state(
47
48
async fn render_request_state (
48
49
template : & Template < SsrNode > ,
49
50
path : & str ,
51
+ req : Request
50
52
) -> Result < ( String , Option < String > ) > {
51
53
// Generate the initial state (this may generate an error, but there's no file that can't exist)
52
- let state = Some ( template. get_request_state ( path. to_string ( ) ) . await ?) ;
54
+ let state = Some ( template. get_request_state ( path. to_string ( ) , req ) . await ?) ;
53
55
// Use that to render the static HTML
54
56
let html = sycamore:: render_to_string ( || template. render_for_template ( state. clone ( ) ) ) ;
55
57
@@ -137,6 +139,7 @@ async fn revalidate(
137
139
// TODO possible further optimizations on this for futures?
138
140
pub async fn get_page (
139
141
path : & str ,
142
+ req : Request ,
140
143
render_cfg : & HashMap < String , String > ,
141
144
templates : & TemplateMap < SsrNode > ,
142
145
config_manager : & impl ConfigManager ,
@@ -280,7 +283,7 @@ pub async fn get_page(
280
283
}
281
284
// Handle request state
282
285
if template. uses_request_state ( ) {
283
- let ( html_val, state) = render_request_state ( template, path) . await ?;
286
+ let ( html_val, state) = render_request_state ( template, path, req ) . await ?;
284
287
// Request-time HTML always overrides anything generated at build-time or incrementally (this has more information)
285
288
html = html_val;
286
289
states. request_state = state;
0 commit comments