Skip to content

How do I stream text data using actix_web and tokio? #3060

Discussion options

You must be logged in to vote

nevermind I already got it!

                    let (tx, mut rx) = tokio::sync::mpsc::channel::<
                        Result<actix_web::web::Bytes, actix_web::Error>,
                    >(10);
                    actix_web::rt::spawn(async move {
                        match tx
                            .send(Ok(actix_web::web::Bytes::from(
                                "List of redirect URLs!\n".to_owned().into_bytes(),
                            )))
                            .await
                        {
                            Ok(_) => {}
                            Err(e) => {
                                log::error!("Something went wrong when streaming data!: {}",…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@robjtede
Comment options

Answer selected by timelessnesses
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants