]>
code.octet-stream.net Git - broadcaster/blob - radio/config.go
9 "github.com/BurntSushi/toml"
12 type RadioConfig
struct {
22 func NewRadioConfig() RadioConfig
{
24 GpioDevice
: "gpiochip0",
30 TimeZone
: "Australia/Hobart",
34 func (c
*RadioConfig
) LoadFromFile(path
string) {
35 _
, err
:= toml
.DecodeFile(path
, &c
)
37 log
.Fatal("could not read config file for reading at path:", path
, err
)
46 func (c
*RadioConfig
) Validate() error
{
47 if c
.ServerURL
== "" {
48 return errors
.New("ServerURL must be provided in the configuration")
51 return errors
.New("Token must be provided in the configuration")
56 func (c
*RadioConfig
) ApplyDefaults() {
57 if c
.CachePath
== "" {
58 dir
, err
:= os
.MkdirTemp("", "broadcast")
66 func (c
*RadioConfig
) WebsocketURL() string {
67 addr
:= strings
.Replace(c
.ServerURL
, "https://", "wss://", -1)
68 addr
= strings
.Replace(addr
, "http://", "ws://", -1)
69 return addr
+ "/radio-ws"