diff --git a/api.go b/api.go index e341693..8cd4909 100644 --- a/api.go +++ b/api.go @@ -26,7 +26,7 @@ func main() { mux.Get("/p/:sessionId", h) mux.Get("/assets/*", http.FileServer(http.Dir("./www"))) - mux.Get("/exec/:id", websocket.Handler(handlers.Exec)) + mux.Get("/sessions/:sessionId/instances/:instanceId/attach", websocket.Handler(handlers.Exec)) n := negroni.Classic() n.UseHandler(mux) diff --git a/handlers/exec.go b/handlers/exec.go index e90b497..005aca1 100644 --- a/handlers/exec.go +++ b/handlers/exec.go @@ -12,7 +12,7 @@ import ( // Echo the data received on the WebSocket. func Exec(ws *websocket.Conn) { - id := bone.GetValue(ws.Request(), "id") + id := bone.GetValue(ws.Request(), "instanceId") ctx := context.Background() conn, err := services.GetExecConnection(id, ctx) if err != nil { @@ -29,8 +29,4 @@ func Exec(ws *websocket.Conn) { select { case <-ctx.Done(): } - //io.Copy(ws, os.Stdout) - //go func() { - //io.Copy(*conn, ws) - //}() } diff --git a/www/assets/app.js b/www/assets/app.js index a9f2a71..a82af41 100644 --- a/www/assets/app.js +++ b/www/assets/app.js @@ -36,7 +36,10 @@ $scope.showInstance($scope.instances[0]); } }, function(response) { - console.log('error', response); + if (response.status == 404) { + document.write('session not found'); + return + } }); } diff --git a/www/assets/main.js b/www/assets/main.js index f91948f..0debe98 100644 --- a/www/assets/main.js +++ b/www/assets/main.js @@ -40,8 +40,9 @@ function createTerminal(name) { term = new Terminal({ cursorBlink: false }); + var sessionId = location.pathname.substr(location.pathname.lastIndexOf("/")+1); protocol = (location.protocol === 'https:') ? 'wss://' : 'ws://'; - socketURL = protocol + location.hostname + ((location.port) ? (':' + location.port) : '') + '/exec/' + name; + socketURL = protocol + location.hostname + ((location.port) ? (':' + location.port) : '') + '/sessions/' + sessionId + '/instances/' + name + '/attach'; term.open(terminalContainer);