feat: add support for specifying custom querystring arguments

This allows folks to implement token-based authentication for websocket access.

Closes #82
This commit is contained in:
Jose Diaz-Gonzalez
2024-02-14 22:56:16 -05:00
committed by Soren L. Hansen
parent 113b502abb
commit ba9326e417
6 changed files with 17 additions and 7 deletions

View File

@@ -8,6 +8,7 @@ import (
"log"
"net/http"
"net/url"
"strings"
"sync/atomic"
"github.com/gorilla/websocket"
@@ -233,7 +234,12 @@ func (server *Server) handleAuthToken(w http.ResponseWriter, r *http.Request) {
func (server *Server) handleConfig(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/javascript")
w.Write([]byte("var gotty_term = 'xterm';"))
lines := []string{
"var gotty_term = 'xterm';",
"var gotty_ws_query_args = '" + server.options.WSQueryArgs + "';",
}
w.Write([]byte(strings.Join(lines, "\n")))
}
// titleVariables merges maps in a specified order.