28 lines
566 B
Go
28 lines
566 B
Go
|
package server
|
||
|
|
||
|
import (
|
||
|
"io"
|
||
|
|
||
|
"github.com/pelletier/go-toml/v2"
|
||
|
)
|
||
|
|
||
|
type Config struct {
|
||
|
ListenAddr string `toml:"ListenAddr"`
|
||
|
NATSAddr string `toml:"NATSAddr"`
|
||
|
BaseSubject string `toml:"BaseSubject"`
|
||
|
|
||
|
UserServiceBaseURL string `toml:"UserServiceBaseURL"`
|
||
|
AuthServiceBaseURL string `toml:"AuthServiceBaseURL"`
|
||
|
MovieServiceBaseURL string `toml:"MovieServiceBaseURL"`
|
||
|
}
|
||
|
|
||
|
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
|
||
|
}
|