auth/server/config.go

33 lines
625 B
Go
Raw Normal View History

2023-10-21 08:26:15 +00:00
package server
import (
"io"
"github.com/pelletier/go-toml/v2"
)
type Config struct {
2023-10-27 19:46:09 +00:00
ListenAddr string `toml:"ListenAddr"`
NATS *NATSConfig `toml:"NATS"`
BaseSubject string `toml:"BaseSubject"`
2023-10-21 08:26:15 +00:00
UserServiceBaseURL string `toml:"UserServiceBaseURL"`
}
2023-10-27 19:46:09 +00:00
type NATSConfig struct {
Enabled bool `toml:"Enabled"`
NKeySeed string `toml:"NKeySeed"`
Addr string `toml:"Addr"`
Subject string `toml:"Subject"`
}
2023-10-21 08:26:15 +00:00
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
}