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:
parent
66c749d5f0
commit
68d881291c
11 changed files with 130 additions and 41 deletions
client
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue