Skip to content

Commit 93a8646

Browse files
committed
fix README example in roa
Signed-off-by: Hexilee <i@hexilee.me>
1 parent 1e42df1 commit 93a8646

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

roa/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,16 +129,16 @@ async fn main() -> Result<(), Box<dyn StdError>> {
129129

130130
async 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

137137
async 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

Comments
 (0)