forked from openfresh/wse-rest-library-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample_test.go
51 lines (42 loc) · 1.26 KB
/
example_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package wserest_test
import (
"fmt"
"log"
"os"
wserest "github.com/sebastien4/wse-rest-library-go"
"github.com/sebastien4/wse-rest-library-go/entity/application/helper"
)
var UseWowza = getenv("USE_WOWZA", "")
var WowzaHost = getenv("WOWZA_HOST", "http://111.111.123.123:8087/v2")
var WowzaServerInstance = getenv("WOWZA_SERVER_INSTANCE", "_defaultServer_")
var WowzaVhostInstance = getenv("WOWZA_VHOST_INSTANCE", "_defaultVHost_")
var WowzaUsername = getenv("WOWZA_USERNAME", "my_secret_username")
var WowzaPassword = getenv("WOWZA_PASSWORD", "my_super_cool_password")
func getenv(key, fallback string) string {
value := os.Getenv(key)
if len(value) == 0 {
return fallback
}
return value
}
func Example() {
// It is simple to create a setup object for transporting our settings
setup := helper.NewDefaultSettings()
setup.SetHost(WowzaHost)
setup.SetUseDigest(true)
setup.SetUsername(WowzaUsername)
setup.SetPassword(WowzaPassword)
// Connect to the server or deal with statistics NOTICE THE CAPS IN COM AND WOWZA
server := wserest.NewServer(setup)
sf := wserest.NewStatistics(setup)
if UseWowza == "" {
fmt.Println(2)
return
}
response, err := sf.GetServerStatistics(server)
if err != nil {
log.Fatal(err)
}
fmt.Println(len(response))
// Output: 2
}