web_queue_meta/
api.rs

1use actix_web::dev::{Factory, HttpServiceFactory};
2use actix_web::{web, FromRequest, Responder, Scope};
3use std::future::Future;
4
5pub fn queue_scope_factory<CREATE, SEND, CLOSE, LONGPOLL, WEBSOCKET, I, R, U>(
6    create_queue: CREATE,
7    send_to_queue: SEND,
8    close_queue: CLOSE,
9    subscribe_queue_longpoll: LONGPOLL,
10    subscribe_queue_ws: WEBSOCKET,
11) -> Scope
12where
13    CREATE: HttpServiceFactory + 'static,
14    SEND: HttpServiceFactory + 'static,
15    CLOSE: HttpServiceFactory + 'static,
16    LONGPOLL: HttpServiceFactory + 'static,
17    WEBSOCKET: Factory<I, R, U> + 'static,
18    I: FromRequest + 'static,
19    R: Future<Output = U> + 'static,
20    U: Responder + 'static,
21{
22    web::scope("/queue")
23        .service(create_queue)
24        .service(send_to_queue)
25        .service(close_queue)
26        .service(subscribe_queue_longpoll)
27        .service(web::resource("/listen/ws/{queue_name}/{uniq_id}").to(subscribe_queue_ws))
28}