pub fn graphql_protocol(
) -> impl Filter<Extract = (WebSocketProtocols,), Error = Rejection> + Clone
Expand description

Create a Filter that parse WebSocketProtocols from sec-websocket-protocol header.

Examples found in repository?
src/subscription.rs (line 66)
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
pub fn graphql_subscription<E>(
    executor: E,
) -> impl Filter<Extract = (impl Reply,), Error = Rejection> + Clone
where
    E: Executor,
{
    warp::ws()
        .and(graphql_protocol())
        .map(move |ws: ws::Ws, protocol| {
            let executor = executor.clone();

            let reply = ws.on_upgrade(move |socket| {
                GraphQLWebSocket::new(socket, executor, protocol)
                    .on_connection_init(default_on_connection_init)
                    .serve()
            });

            warp::reply::with_header(
                reply,
                "Sec-WebSocket-Protocol",
                protocol.sec_websocket_protocol(),
            )
        })
}