You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
548 B
Go
45 lines
548 B
Go
8 years ago
|
package main
|
||
|
|
||
|
import (
|
||
|
//"fmt"
|
||
|
"github.com/go-yaml/yaml"
|
||
|
"io/ioutil"
|
||
|
)
|
||
|
|
||
|
type server struct {
|
||
|
Listen listen
|
||
|
Backend backend
|
||
|
}
|
||
|
|
||
|
type conf []server
|
||
|
|
||
|
type listen struct {
|
||
|
Host string
|
||
|
Port int
|
||
|
Cert string
|
||
|
Key string
|
||
|
}
|
||
|
|
||
|
type backend struct {
|
||
|
Host string
|
||
|
Port int
|
||
|
Hostname string
|
||
|
TLS bool
|
||
|
Insecure bool
|
||
|
}
|
||
|
|
||
|
func loadConfig(fn string) (*conf, error) {
|
||
|
data, err := ioutil.ReadFile(fn)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
|
||
|
c := new(conf)
|
||
|
err = yaml.Unmarshal(data, c)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
|
||
|
return c, nil
|
||
|
}
|