Documentation ¶
Index ¶
- Variables
- func Register(name string, configHandler configHandler) error
- func Use(name string) (configHandler, error)
- type Callback
- type Handler
- type Instance
- func (this *Instance) AddConfigPath(in string)
- func (this *Instance) BindedEnvironmentKeys() []string
- func (this *Instance) Callbacks(ctx context.Context, callbacks map[string]Callback) (context.Context, error)
- func (this *Instance) ConfigFileUsed() string
- func (this *Instance) GetBool(key string) bool
- func (this *Instance) GetDuration(key string) time.Duration
- func (this *Instance) GetFloat64(key string) float64
- func (this *Instance) GetInt(key string) int
- func (this *Instance) GetInt64(key string) int64
- func (this *Instance) GetPathPrefix() string
- func (this *Instance) GetSizeInBytes(key string) uint
- func (this *Instance) GetString(key string) string
- func (this *Instance) GetStringMap(key string) map[string]interface{}
- func (this *Instance) GetStringMapString(key string) map[string]string
- func (this *Instance) GetStringMapStringSlice(key string) map[string][]string
- func (this *Instance) GetStringSlice(key string) []string
- func (this *Instance) GetTime(key string) time.Time
- func (this *Instance) GetValue(key string) interface{}
- func (this *Instance) HandlerName() string
- func (this *Instance) Initiate(ctx context.Context) (context.Context, error)
- func (this *Instance) LoadFromConfigFile(configFile string) error
- func (this *Instance) LoadFromConfigPath(configName string) error
- func (this *Instance) LoadFromEnv() error
- func (this *Instance) LoadFromEnvFile(dotEnvFile string) error
- func (this *Instance) OnRequestShutdown(c *routing.Context) error
- func (this *Instance) OnRequestStartup(c *routing.Context) error
- func (this *Instance) OnShutdown(ctx context.Context) (context.Context, error)
- func (this *Instance) OnStartup(ctx context.Context) (context.Context, error)
- func (this *Instance) SetEnvPrefix(in string)
- func (this *Instance) SetOptions(ctx context.Context, options map[string]Option) (context.Context, error)
- func (this *Instance) SetPathPrefix(pathPrefix string)
- func (this *Instance) SetValue(key string, value interface{})
- func (this *Instance) Use(ctx context.Context, handlerName string) error
- func (this *Instance) WithContextValue(ctx context.Context, keymaps map[string]string)
- type Option
- type Type
- type ViperHandler
- func (this *ViperHandler) AddConfigPath(in string)
- func (this *ViperHandler) BindEnv(in string) error
- func (this *ViperHandler) ConfigFileUsed() string
- func (this *ViperHandler) Get(key string) interface{}
- func (this *ViperHandler) GetBool(key string) bool
- func (this *ViperHandler) GetDuration(key string) time.Duration
- func (this *ViperHandler) GetFloat64(key string) float64
- func (this *ViperHandler) GetInt(key string) int
- func (this *ViperHandler) GetInt64(key string) int64
- func (this *ViperHandler) GetSizeInBytes(key string) uint
- func (this *ViperHandler) GetString(key string) string
- func (this *ViperHandler) GetStringMap(key string) map[string]interface{}
- func (this *ViperHandler) GetStringMapString(key string) map[string]string
- func (this *ViperHandler) GetStringMapStringSlice(key string) map[string][]string
- func (this *ViperHandler) GetStringSlice(key string) []string
- func (this *ViperHandler) GetTime(key string) time.Time
- func (this *ViperHandler) Initiate(ctx context.Context) error
- func (this *ViperHandler) ReadInConfig() error
- func (this *ViperHandler) Set(key string, value interface{})
- func (this *ViperHandler) SetConfigFile(in string)
- func (this *ViperHandler) SetConfigName(in string)
- func (this *ViperHandler) SetDefault(key string, value interface{})
- func (this *ViperHandler) SetEnvPrefix(in string)
Constants ¶
This section is empty.
Variables ¶
var Realpath = func(ctx context.Context, value interface{}) (interface{}, error) { ctxPathPrefix := ctx.Value("PATH_PREFIX") if ctxPathPrefix != nil { if prefixPath, ok := ctxPathPrefix.(string); ok { if path, ok := value.(string); ok { if path != "" { if !strings.HasPrefix(path, "/") { return strings.TrimRight(prefixPath, "/") + "/" + path, nil } } } } } return value, nil }
Functions ¶
Types ¶
type Handler ¶
type Handler interface { Initiate(ctx context.Context) error AddConfigPath(in string) SetConfigName(in string) SetConfigFile(in string) ConfigFileUsed() string SetDefault(key string, value interface{}) BindEnv(in string) error SetEnvPrefix(in string) ReadInConfig() error Set(key string, value interface{}) Get(key string) interface{} // GetString returns the value associated with the key as a string. GetString(key string) string // GetBool returns the value associated with the key as a boolean. GetBool(key string) bool // GetInt returns the value associated with the key as an integer. GetInt(key string) int // GetInt64 returns the value associated with the key as an integer. GetInt64(key string) int64 // GetFloat64 returns the value associated with the key as a float64. GetFloat64(key string) float64 // GetTime returns the value associated with the key as time. GetTime(key string) time.Time // GetDuration returns the value associated with the key as a duration. GetDuration(key string) time.Duration // GetStringSlice returns the value associated with the key as a slice of strings. GetStringSlice(key string) []string // GetStringMap returns the value associated with the key as a map of interfaces. GetStringMap(key string) map[string]interface{} // GetStringMapString returns the value associated with the key as a map of strings. GetStringMapString(key string) map[string]string // GetStringMapStringSlice returns the value associated with the key as a map to a slice of strings. GetStringMapStringSlice(key string) map[string][]string // GetSizeInBytes returns the size of the value associated with the given key // in bytes. GetSizeInBytes(key string) uint }
func NewViperHandler ¶
func NewViperHandler() Handler
type Instance ¶
type Instance struct {
// contains filtered or unexported fields
}
func NewInstance ¶
func NewInstance() *Instance
func (*Instance) AddConfigPath ¶
func (*Instance) BindedEnvironmentKeys ¶
func (*Instance) ConfigFileUsed ¶
func (*Instance) GetDuration ¶
GetDuration returns the value associated with the key as a duration.
func (*Instance) GetFloat64 ¶
GetFloat64 returns the value associated with the key as a float64.
func (*Instance) GetPathPrefix ¶
func (*Instance) GetSizeInBytes ¶
GetSizeInBytes returns the size of the value associated with the given key in bytes.
func (*Instance) GetStringMap ¶
GetStringMap returns the value associated with the key as a map of interfaces.
func (*Instance) GetStringMapString ¶
GetStringMapString returns the value associated with the key as a map of strings.
func (*Instance) GetStringMapStringSlice ¶
GetStringMapStringSlice returns the value associated with the key as a map to a slice of strings.
func (*Instance) GetStringSlice ¶
GetStringSlice returns the value associated with the key as a slice of strings.
func (*Instance) HandlerName ¶
func (*Instance) LoadFromConfigFile ¶
func (*Instance) LoadFromConfigPath ¶
func (*Instance) LoadFromEnv ¶
func (*Instance) LoadFromEnvFile ¶
func (*Instance) OnRequestShutdown ¶
func (*Instance) OnRequestStartup ¶
func (*Instance) OnShutdown ¶
func (*Instance) SetEnvPrefix ¶
func (*Instance) SetOptions ¶
func (*Instance) SetPathPrefix ¶
type ViperHandler ¶
func (*ViperHandler) AddConfigPath ¶
func (this *ViperHandler) AddConfigPath(in string)
func (*ViperHandler) BindEnv ¶
func (this *ViperHandler) BindEnv(in string) error
func (*ViperHandler) ConfigFileUsed ¶
func (this *ViperHandler) ConfigFileUsed() string
func (*ViperHandler) Get ¶
func (this *ViperHandler) Get(key string) interface{}
func (*ViperHandler) GetBool ¶
func (this *ViperHandler) GetBool(key string) bool
GetBool returns the value associated with the key as a boolean.
func (*ViperHandler) GetDuration ¶
func (this *ViperHandler) GetDuration(key string) time.Duration
GetDuration returns the value associated with the key as a duration.
func (*ViperHandler) GetFloat64 ¶
func (this *ViperHandler) GetFloat64(key string) float64
GetFloat64 returns the value associated with the key as a float64.
func (*ViperHandler) GetInt ¶
func (this *ViperHandler) GetInt(key string) int
GetInt returns the value associated with the key as an integer.
func (*ViperHandler) GetInt64 ¶
func (this *ViperHandler) GetInt64(key string) int64
GetInt64 returns the value associated with the key as an integer.
func (*ViperHandler) GetSizeInBytes ¶
func (this *ViperHandler) GetSizeInBytes(key string) uint
GetSizeInBytes returns the size of the value associated with the given key in bytes.
func (*ViperHandler) GetString ¶
func (this *ViperHandler) GetString(key string) string
GetString returns the value associated with the key as a string.
func (*ViperHandler) GetStringMap ¶
func (this *ViperHandler) GetStringMap(key string) map[string]interface{}
GetStringMap returns the value associated with the key as a map of interfaces.
func (*ViperHandler) GetStringMapString ¶
func (this *ViperHandler) GetStringMapString(key string) map[string]string
GetStringMapString returns the value associated with the key as a map of strings.
func (*ViperHandler) GetStringMapStringSlice ¶
func (this *ViperHandler) GetStringMapStringSlice(key string) map[string][]string
GetStringMapStringSlice returns the value associated with the key as a map to a slice of strings.
func (*ViperHandler) GetStringSlice ¶
func (this *ViperHandler) GetStringSlice(key string) []string
GetStringSlice returns the value associated with the key as a slice of strings.
func (*ViperHandler) GetTime ¶
func (this *ViperHandler) GetTime(key string) time.Time
GetTime returns the value associated with the key as time.
func (*ViperHandler) ReadInConfig ¶
func (this *ViperHandler) ReadInConfig() error
func (*ViperHandler) Set ¶
func (this *ViperHandler) Set(key string, value interface{})
func (*ViperHandler) SetConfigFile ¶
func (this *ViperHandler) SetConfigFile(in string)
func (*ViperHandler) SetConfigName ¶
func (this *ViperHandler) SetConfigName(in string)
func (*ViperHandler) SetDefault ¶
func (this *ViperHandler) SetDefault(key string, value interface{})
func (*ViperHandler) SetEnvPrefix ¶
func (this *ViperHandler) SetEnvPrefix(in string)