mirror of
https://github.com/hamburghammer/gmon.git
synced 2024-05-03 22:55:25 +02:00
29 lines
560 B
Go
29 lines
560 B
Go
package config
|
|
|
|
import (
|
|
"io"
|
|
|
|
"github.com/pelletier/go-toml"
|
|
)
|
|
|
|
// TOMLRulesLoader handels the reading of rules.
|
|
type TOMLRulesLoader struct {
|
|
reader io.Reader
|
|
}
|
|
|
|
// Load reads the rules and returns them.
|
|
func (trl TOMLRulesLoader) Load() (Rules, error) {
|
|
rules := Rules{}
|
|
err := toml.NewDecoder(trl.reader).Decode(&rules)
|
|
if err != nil {
|
|
return Rules{}, err
|
|
}
|
|
|
|
return rules, nil
|
|
}
|
|
|
|
// NewTOMLRulesLoader is a constructor for the TOMLRulesLoader.
|
|
func NewTOMLRulesLoader(reader io.Reader) TOMLRulesLoader {
|
|
return TOMLRulesLoader{reader: reader}
|
|
}
|