make webterm_socket endpoint configurable
This commit is contained in:
parent
c232123bf9
commit
6bdfd1118a
10
src/main.rs
10
src/main.rs
@ -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")
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user