]>
code.octet-stream.net Git - broadcaster/blob - broadcaster-radio/config.go
6837b7dd10bff49735ddc9e789d5322038136fa4
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"