mirror of
https://github.com/Xevion/go-ha.git
synced 2025-12-06 01:15:10 -06:00
two url fixes:
- default scheme for legacy connection params - set paths for http and websocket APIs
This commit is contained in:
4
app.go
4
app.go
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user