Torjus Håkestad
affae5941b
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
30 lines
605 B
Go
30 lines
605 B
Go
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
|
|
}
|