How do I return a future from an actix-web responder?

Unfortunately there doesn't seem to be really anything in actix-web's documentation on how to actually use their Responder trait other than an incredibly simple example using Ready to generate a future that's already finished. How do I return some actual async code here? e. g.

impl Responder for MyResponder {
    type Error = Error;
    type Future = What goes here?;

    fn respond_to(self, req: &HttpRequest) -> Self::Future {
        async { Ok() }

async {} blocks have a type that is impossible to name.

However, if you wrap it in a Box, then the type will be

Box<dyn Future<Output=Result<(), Error>>

plus it needs Send and a lifetime. There's .boxed() method and BoxFuture alias for this:

If on nightly, you can use #![feature(min_type_alias_impl_trait)] and type Future = impl Future<Output = ...>.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.