add optional endpoint to new client

This commit is contained in:
Adrian Zuercher
2025-08-24 21:18:43 +02:00
parent 756985882a
commit 567d2fe03d
2 changed files with 6 additions and 3 deletions

View File

@@ -57,8 +57,11 @@ var upgrader = websocket.Upgrader{
EnableCompression: false,
}
func NewClient(ip, id string, port uint, logger *logging.Logger) (*Client, error) {
u := url.URL{Scheme: "ws", Host: fmt.Sprintf("%s:%d", ip, port), Path: "status", RawQuery: "id=" + id}
func NewClient(id, ip, endpoint string, port uint, logger *logging.Logger) (*Client, error) {
if endpoint == "" {
endpoint = "status"
}
u := url.URL{Scheme: "ws", Host: fmt.Sprintf("%s:%d", ip, port), Path: endpoint, RawQuery: "id=" + id}
c := &Client{
id: id,