mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-11-02 01:07:28 -04:00
26 lines
479 B
Go
26 lines
479 B
Go
|
package json
|
||
|
|
||
|
type ConfigObjectCreator func() interface{}
|
||
|
|
||
|
var (
|
||
|
configCache map[string]ConfigObjectCreator
|
||
|
)
|
||
|
|
||
|
func RegisterRouterConfig(strategy string, creator ConfigObjectCreator) error {
|
||
|
// TODO: check strategy
|
||
|
configCache[strategy] = creator
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
func CreateRouterConfig(strategy string) interface{} {
|
||
|
creator, found := configCache[strategy]
|
||
|
if !found {
|
||
|
return nil
|
||
|
}
|
||
|
return creator()
|
||
|
}
|
||
|
|
||
|
func init() {
|
||
|
configCache = make(map[string]ConfigObjectCreator)
|
||
|
}
|