@@ -129,16 +129,16 @@ async fn main() -> Result<(), Box<dyn StdError>> {
129129
130130async fn logger (ctx : & mut Context , next : Next <'_ >) -> roa :: Result {
131131 next . await ? ;
132- let rt = ctx . resp . must_get (" x-response-time" )? ;
133- info! (" {} {} - {}" , ctx . method (), ctx . uri (), rt );
132+ let rt = ctx . load :: < String > (" x-response-time" ). unwrap () ;
133+ info! (" {} {} - {}" , ctx . method (), ctx . uri (), rt . as_str () );
134134 Ok (())
135135}
136136
137137async fn x_response_time (ctx : & mut Context , next : Next <'_ >) -> roa :: Result {
138138 let start = Instant :: now ();
139139 next . await ? ;
140140 let ms = start . elapsed (). as_millis ();
141- ctx . resp . insert (" x-response-time" , format! (" {}ms" , ms ))? ;
141+ ctx . store (" x-response-time" , format! (" {}ms" , ms ));
142142 Ok (())
143143}
144144
@@ -160,7 +160,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
160160 let app = App::new()
161161 .gate(catch)
162162 .gate(not_catch)
163- .end(status!(StatusCode::IM_A_TEAPOT, "I'm a teapot!");
163+ .end(status!(StatusCode::IM_A_TEAPOT, "I'm a teapot!")) ;
164164 app.listen("127.0.0.1:8000", |addr| {
165165 info!("Server is listening on {}", addr)
166166 })?
0 commit comments