1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
use crate::stream_rpc::transport::websocket::get_websocket_routes;
use diem_config::config::StreamConfig;
use std::sync::Arc;
use storage_interface::MoveDbReader;
use warp::{filters::BoxedFilter, Filter, Reply};
pub fn get_stream_routes(
config: &StreamConfig,
content_length_limit: u64,
diem_db: Arc<dyn MoveDbReader>,
) -> BoxedFilter<(impl Reply,)> {
let wss_routes = get_websocket_routes(config, content_length_limit, diem_db.clone(), None).0;
let is_enabled = config.enabled;
warp::any()
.and_then(move || {
futures::future::ready(if is_enabled {
Ok(())
} else {
Err(warp::reject::not_found())
})
})
.untuple_one()
.and(wss_routes)
.boxed()
}