1
0
Fork 0
mirror of https://github.com/binwiederhier/ntfy.git synced 2025-06-15 09:03:20 +02:00

Docs, LoadConfig, config test

This commit is contained in:
Philipp Heckel 2021-12-22 13:46:17 +01:00
parent 66c749d5f0
commit 68d881291c
11 changed files with 130 additions and 41 deletions
client

View file

@ -1,5 +1,10 @@
package client
import (
"gopkg.in/yaml.v2"
"os"
)
const (
// DefaultBaseURL is the base URL used to expand short topic names
DefaultBaseURL = "https://ntfy.sh"
@ -22,3 +27,16 @@ func NewConfig() *Config {
Subscribe: nil,
}
}
// LoadConfig loads the Client config from a yaml file
func LoadConfig(filename string) (*Config, error) {
b, err := os.ReadFile(filename)
if err != nil {
return nil, err
}
c := NewConfig()
if err := yaml.Unmarshal(b, c); err != nil {
return nil, err
}
return c, nil
}