WebSocket support

rustdocs (main)

use futures_util::StreamExt;
use trillium_websockets::{Message, WebSocket};

pub fn main() {
    env_logger::init();

    trillium_smol::run(WebSocket::new(|mut websocket| async move {
        while let Some(Ok(Message::Text(input))) = websocket.next().await {
            websocket
                .send_string(format!("received your message: {}", &input))
                .await;
        }
    }));
}

🌊 WebSockets work a lot like tide's, since I recently wrote that interface as well. One difference in trillium is that the websocket connection also contains some aspects of the original http request, such as request headers, the request path and method, and any state that has been accumulated by previous handlers in a sequence.