External state in an async hyper service_fn

I want to propagate state to hyper's service_fn, which takes a single parameter, the request. As the example suggests, you can work around this by using a closure. But, I am going to need to concatenate the request body in order to parse it, and I have only seen it done asynchronously - which is currently not possible inside a closure on stable.

How do I work around this?

I managed to resolve it, it needed an async move block right inside the closure, like so:

service_fn(move |req: Request<Body>| async move { ...

I can finally go to sleep now.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.