zrok/endpoints/publicFrontend/config.go

38 lines
678 B
Go
Raw Normal View History

2022-12-14 20:40:45 +01:00
package publicFrontend
import (
"github.com/michaelquigley/cf"
"github.com/pkg/errors"
"time"
)
type Config struct {
Identity string
Metrics *MetricsConfig
Address string
HostMatch string
}
type MetricsConfig struct {
2022-10-18 17:57:32 +02:00
Service string
SendTimeout time.Duration
}
func DefaultConfig() *Config {
return &Config{
Identity: "frontend",
Metrics: &MetricsConfig{
2022-10-18 17:57:32 +02:00
Service: "metrics",
SendTimeout: 5 * time.Second,
},
Address: "0.0.0.0:8080",
}
}
func (c *Config) Load(path string) error {
if err := cf.BindYaml(c, path, cf.DefaultOptions()); err != nil {
return errors.Wrapf(err, "error loading frontend config '%v'", path)
}
return nil
}