Support streaming via API key (#1279)

* Support api key via url query parameter
* Add api key to stream URL
This commit is contained in:
WithoutPants
2021-04-12 11:05:49 +10:00
committed by GitHub
parent f6ffda7504
commit f5dc654f6b
4 changed files with 19 additions and 2 deletions

View File

@@ -1,6 +1,7 @@
package urlbuilders
import (
"fmt"
"strconv"
"time"
)
@@ -8,6 +9,7 @@ import (
type SceneURLBuilder struct {
BaseURL string
SceneID string
APIKey string
}
func NewSceneURLBuilder(baseURL string, sceneID int) SceneURLBuilder {
@@ -18,7 +20,11 @@ func NewSceneURLBuilder(baseURL string, sceneID int) SceneURLBuilder {
}
func (b SceneURLBuilder) GetStreamURL() string {
return b.BaseURL + "/scene/" + b.SceneID + "/stream"
var apiKeyParam string
if b.APIKey != "" {
apiKeyParam = fmt.Sprintf("?apikey=%s", b.APIKey)
}
return fmt.Sprintf("%s/scene/%s/stream%s", b.BaseURL, b.SceneID, apiKeyParam)
}
func (b SceneURLBuilder) GetStreamPreviewURL() string {