gpaste/config.go

30 lines
605 B
Go
Raw Normal View History

2022-01-15 21:01:53 +00:00
package gpaste
import (
"fmt"
"io"
"github.com/pelletier/go-toml"
)
type ServerConfig struct {
LogLevel string `toml:"LogLevel"`
URL string `toml:"URL"`
ListenAddr string `toml:"ListenAddr"`
Store *ServerStoreConfig `toml:"Store"`
}
type ServerStoreConfig struct {
Type string `toml:"Type"`
}
func ServerConfigFromReader(r io.Reader) (*ServerConfig, error) {
decoder := toml.NewDecoder(r)
var c ServerConfig
if err := decoder.Decode(&c); err != nil {
return nil, fmt.Errorf("error decoding server config: %w", err)
}
return &c, nil
}