users/server/config.go

24 lines
396 B
Go
Raw Normal View History

2023-10-19 21:15:55 +00:00
package server
import (
"io"
"github.com/pelletier/go-toml/v2"
)
type Config struct {
ListenAddr string `toml:"ListenAddr"`
NATSAddr string `toml:"NATSAddr"`
NATSSubject string `toml:"NATSSubject"`
}
func ConfigFromReader(r io.Reader) (*Config, error) {
decoder := toml.NewDecoder(r)
var c Config
if err := decoder.Decode(&c); err != nil {
return nil, err
}
return &c, nil
}