make webterm_socket endpoint configurable

This commit is contained in:
Fabian Freyer 2019-03-29 09:42:50 -04:00
parent c232123bf9
commit 6bdfd1118a

View File

@ -318,14 +318,12 @@ impl Handler<event::TerminadoMessage> for Terminal {
/// Trait to extend an [actix_web::App] by serving a web terminal. /// Trait to extend an [actix_web::App] by serving a web terminal.
pub trait WebTermExt { pub trait WebTermExt {
/// Serve the websocket for the webterm /// Serve the websocket for the webterm
fn webterm_socket(self: Self) -> Self; fn webterm_socket(self: Self, endpoint: &str) -> Self;
} }
impl WebTermExt for App<()> { impl WebTermExt for App<()> {
fn webterm_socket(self: Self) -> Self {; fn webterm_socket(self: Self, endpoint: &str) -> Self {
self.resource("/websocket", |r| { self.resource(endpoint, |r| r.f(|req| ws::start(req, Websocket::new())))
r.f(|req| ws::start(req, Websocket::new()))
})
} }
} }
@ -340,7 +338,7 @@ fn main() {
.unwrap() .unwrap()
.show_files_listing(), .show_files_listing(),
) )
.webterm_socket() .webterm_socket("/websocket")
.resource("/", |r| r.f(index)) .resource("/", |r| r.f(index))
}) })
.bind("127.0.0.1:8080") .bind("127.0.0.1:8080")