Integration

Dynamic Configuration

Embed *values.DynamicValues in the project common.Values.

Similarly, if you want to customize more configurations, you can first define a common.Extra embedded *values.DynamicValues, and then embed common.Values into it.

type Values struct {
    Mode      string `env:"MODE" envDefault:"debug"`
	Hostname  string `env:"HOSTNAME"`
	Address   string `env:"ADDRESS" envDefault:":3000"`
    ...
    *Extra
}

type Extra struct {
    IpAddress             string `yaml:"ip_address"`
	IpSecretId            string `yaml:"ip_secret_id"`
	IpSecretKey           string `yaml:"ip_secret_key" secret:"*"`
    ...
    *values.DynamicValues `yaml:"dynamic_values"`
}

The tag secret means desensitization, and only shows whether state is set in the /values return.

Add loading in bootstrap.go

Also define configuration loading

Add it in wire.go

Then dependency in api.go and establish routing

Final execution generates wire_gen.go

Sessions

First define configuration loading in bootstrap.go

Add it in wire.go

Dependency in api.go and establish routing

Final execution generates wire_gen.go

Mongo REST

First define configuration loading in bootstrap.go

Add it in wire.go

Dependency in api.go and establish routing

Final execution generates wire_gen.go

Last updated

Was this helpful?