-
Notifications
You must be signed in to change notification settings - Fork 0
/
provider.go
40 lines (33 loc) · 1.22 KB
/
provider.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package config
import (
"github.com/karry-11110/ginx/framework"
"github.com/karry-11110/ginx/framework/contract"
"path/filepath"
)
type GinxConfigProvider struct{}
// Register registe a new function for make a service instance
func (provider *GinxConfigProvider) Register(c framework.Container) framework.NewInstance {
return NewGinxConfig
}
// Boot will called when the service instantiate
func (provider *GinxConfigProvider) Boot(c framework.Container) error {
return nil
}
// IsDefer define whether the service instantiate when first make or register
func (provider *GinxConfigProvider) IsDefer() bool {
return false
}
// Params define the necessary params for NewInstance
func (provider *GinxConfigProvider) Params(c framework.Container) []interface{} {
appService := c.MustMake(contract.AppKey).(contract.App)
envService := c.MustMake(contract.EnvKey).(contract.Env)
env := envService.AppEnv()
// 配置文件夹地址
configFolder := appService.ConfigFolder()
envFolder := filepath.Join(configFolder, env)
return []interface{}{c, envFolder, envService.All()}
}
/// Name define the name for this service
func (provider *GinxConfigProvider) Name() string {
return contract.ConfigKey
}