Open jk-gan opened 4 years ago
I fixed it by making the method doesn't own the ctx
:
pub fn build(&self, res: impl Responder) -> ResponseBuilder {
ResponseBuilder::new(res.respond_to())
}
and now I'm getting this error for closure:
error[E0515]: cannot return value referencing function parameter `ctx`
--> examples/hello.rs:7:33
|
7 | app.get("/", |ctx: Context| async { ctx.build("Hello World").ok() });
| ^^^^^^^^---^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| | |
| | `ctx` is borrowed here
| returns a value referencing data owned by the current function
I want to use the header value from request and return in Response:
and I get the error: