24 lines
499 B
Go
24 lines
499 B
Go
|
package config
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
"github.com/kelseyhightower/envconfig"
|
||
|
)
|
||
|
|
||
|
type Config struct {
|
||
|
SqHost string `envconfig:"SQ_HOST"`
|
||
|
AppPassword string `envconfig:"APP_PASSWORD"`
|
||
|
Secret string `envconfig:"SECRET"`
|
||
|
DataPath string `envconfig:"DATA_PATH"`
|
||
|
}
|
||
|
|
||
|
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)
|
||
|
}
|