updates go dependencies, refactors config loading precedence, adds gRPC gateway path stripping option, and improves HTTP handler setup.

This commit is contained in:
2025-12-23 13:51:55 -05:00
parent 7cc4e7831e
commit 70e99eef0e
6 changed files with 120 additions and 112 deletions

View File

@@ -50,6 +50,10 @@ func LoadConfig(ctx context.Context) (context.Context, error) {
func loadConfig(configPath string) (*AppConfig, error) {
cfg := *DefaultConfig
if err := env.ParseWithOptions(&cfg, env.Options{DefaultValueTagName: "default"}); err != nil {
return nil, fmt.Errorf("could not parse environment variables: %w", err)
}
if configPath != "" {
file, err := os.Open(configPath)
if err != nil {
@@ -63,10 +67,6 @@ func loadConfig(configPath string) (*AppConfig, error) {
}
}
if err := env.ParseWithOptions(&cfg, env.Options{DefaultValueTagName: "default"}); err != nil {
return nil, fmt.Errorf("could not parse environment variables: %w", err)
}
// Perform updates / enrichments
err := prepareConfig(&cfg)
if err != nil {

View File

@@ -18,4 +18,5 @@ type GRPCConfig struct {
EnableInstrumentation bool `yaml:"enableInstrumentation" env:"APP_GRPC_ENABLE_INSTRUMENTATION" json:"enableInstrumentation,omitempty"` // requires OTEL
EnableGRPCGateway bool `yaml:"enableGRPCGateway" json:"enableGRPCGateway,omitempty" env:"APP_GRPC_ENABLE_GATEWAY" default:"true"`
GRPCGatewayPath string `yaml:"grpcGatewayPath" json:"grpcGatewayPath,omitempty" env:"APP_GRPC_GATEWAY_PATH" default:"/grpc-api"`
GRPCGatewayPathStrip bool `yaml:"grpcGatewayPathStrip" json:"grpcGatewayPathStrip,omitempty" env:"APP_GRPC_GATEWAY_PATH_STRIP" default:"false"`
}