From aa7c0d14abdce85c76168dc3a3b1f116c827c782 Mon Sep 17 00:00:00 2001 From: Jordan Hotmann Date: Thu, 14 Dec 2023 11:27:30 -0700 Subject: [PATCH] Only add channel param if specified --- pkg/amcrest/api.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/amcrest/api.go b/pkg/amcrest/api.go index ed7e841..b49efd7 100644 --- a/pkg/amcrest/api.go +++ b/pkg/amcrest/api.go @@ -31,12 +31,12 @@ type GetSnapshotResponse struct { // // channel int (optional): the channel index (starts at 1) func (c *AmcrestClient) GetSnapshot(channel ...int) (GetSnapshotResponse, error) { - cameraChannel := 1 + req := c.restClient.R() if len(channel) > 0 && channel[0] != 0 { - cameraChannel = channel[0] + req.SetQueryParam("channel", fmt.Sprintf("%d", channel[0])) } - resp, err := util.CheckSuccess(c.restClient.R().SetQueryParam("channel", fmt.Sprintf("%d", cameraChannel)).Get("cgi-bin/snapshot.cgi")) + resp, err := util.CheckSuccess(req.Get("cgi-bin/snapshot.cgi")) if err != nil { return GetSnapshotResponse{}, err }