users/server/config.go

30 lines
521 B
Go

package server
import (
"io"
"github.com/pelletier/go-toml/v2"
)
type Config struct {
ListenAddr string `toml:"ListenAddr"`
NATS *NATSConfig `toml:"NATS"`
}
type NATSConfig struct {
Enabled bool `toml:"Enabled"`
NKeySeed string `toml:"NKeySeed"`
Addr string `toml:"Addr"`
Subject string `toml:"Subject"`
}
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
}