mirror of
https://code.rocketnine.space/tslocum/gmitohtml.git
synced 2024-11-14 19:06:44 +01:00
44 lines
616 B
Go
44 lines
616 B
Go
package main
|
|
|
|
import (
|
|
"crypto/tls"
|
|
"errors"
|
|
"io/ioutil"
|
|
|
|
"gopkg.in/yaml.v3"
|
|
)
|
|
|
|
type certConfig struct {
|
|
Cert string
|
|
Key string
|
|
|
|
cert tls.Certificate
|
|
}
|
|
|
|
type appConfig struct {
|
|
Certs map[string]*certConfig
|
|
}
|
|
|
|
var config = &appConfig{
|
|
Certs: make(map[string]*certConfig),
|
|
}
|
|
|
|
func readconfig(configPath string) error {
|
|
if configPath == "" {
|
|
return errors.New("file unspecified")
|
|
}
|
|
|
|
configData, err := ioutil.ReadFile(configPath)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
var newConfig *appConfig
|
|
err = yaml.Unmarshal(configData, &newConfig)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
config = newConfig
|
|
|
|
return nil
|
|
}
|