23 lines
479 B
Go
23 lines
479 B
Go
package config
|
|
|
|
import (
|
|
"context"
|
|
"github.com/kelseyhightower/envconfig"
|
|
)
|
|
|
|
type Config struct {
|
|
SqHost string `envconfig:"SQ_HOST"`
|
|
Secret string `envconfig:"SECRET"`
|
|
DataPath string `envconfig:"DATA_PATH"`
|
|
Port int `envconfig:"PORT"`
|
|
}
|
|
|
|
func ProcessConfiguration(ctx context.Context) context.Context {
|
|
var cfg Config
|
|
err := envconfig.Process("", &cfg)
|
|
if err != nil {
|
|
panic("failed to process config")
|
|
}
|
|
|
|
return context.WithValue(ctx, "config", cfg)
|
|
}
|