two url fixes:

- default scheme for legacy connection params
- set paths for http and websocket APIs
This commit is contained in:
Sam Lewis
2025-01-19 20:58:16 -05:00
parent c27e596dad
commit 56ccdfbdb2
3 changed files with 6 additions and 0 deletions

4
app.go
View File

@@ -109,6 +109,10 @@ func NewApp(request NewAppRequest) (*App, error) {
if port == "" {
port = "8123"
}
baseURL.Scheme = "http"
if request.Secure {
baseURL.Scheme = "https"
}
baseURL.Host = request.IpAddress + ":" + port
}

View File

@@ -18,6 +18,7 @@ type HttpClient struct {
func NewHttpClient(url *url.URL, token string) *HttpClient {
// Shallow copy the URL to avoid modifying the original
u := *url
u.Path = "/api"
if u.Scheme == "ws" {
u.Scheme = "http"
}

View File

@@ -51,6 +51,7 @@ func ConnectionFromUri(baseURL *url.URL, authToken string) (*websocket.Conn, con
// Shallow copy the URL to avoid modifying the original
urlWebsockets := *baseURL
urlWebsockets.Path = "/api/websocket"
if baseURL.Scheme == "http" {
urlWebsockets.Scheme = "ws"
}