1
0
mirror of https://github.com/bingohuang/docker-labs.git synced 2025-07-15 02:37:27 +08:00

Change attach URL

This commit is contained in:
Marcos Lilljedahl 2016-10-08 10:32:40 +02:00
parent b6b849e2c6
commit 62936fcfc9
4 changed files with 8 additions and 8 deletions

2
api.go
View File

@ -26,7 +26,7 @@ func main() {
mux.Get("/p/:sessionId", h) mux.Get("/p/:sessionId", h)
mux.Get("/assets/*", http.FileServer(http.Dir("./www"))) 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 := negroni.Classic()
n.UseHandler(mux) n.UseHandler(mux)

View File

@ -12,7 +12,7 @@ import (
// Echo the data received on the WebSocket. // Echo the data received on the WebSocket.
func Exec(ws *websocket.Conn) { func Exec(ws *websocket.Conn) {
id := bone.GetValue(ws.Request(), "id") id := bone.GetValue(ws.Request(), "instanceId")
ctx := context.Background() ctx := context.Background()
conn, err := services.GetExecConnection(id, ctx) conn, err := services.GetExecConnection(id, ctx)
if err != nil { if err != nil {
@ -29,8 +29,4 @@ func Exec(ws *websocket.Conn) {
select { select {
case <-ctx.Done(): case <-ctx.Done():
} }
//io.Copy(ws, os.Stdout)
//go func() {
//io.Copy(*conn, ws)
//}()
} }

View File

@ -36,7 +36,10 @@
$scope.showInstance($scope.instances[0]); $scope.showInstance($scope.instances[0]);
} }
}, function(response) { }, function(response) {
console.log('error', response); if (response.status == 404) {
document.write('session not found');
return
}
}); });
} }

View File

@ -40,8 +40,9 @@ function createTerminal(name) {
term = new Terminal({ term = new Terminal({
cursorBlink: false cursorBlink: false
}); });
var sessionId = location.pathname.substr(location.pathname.lastIndexOf("/")+1);
protocol = (location.protocol === 'https:') ? 'wss://' : 'ws://'; 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); term.open(terminalContainer);