代码拉取完成,页面将自动刷新
/*
Copyright IBM Corp All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
package library
import (
"github.com/mitchellh/mapstructure"
"github.com/spf13/viper"
)
// Config configures the factory methods
// and plugins for the registry
type Config struct {
AuthFilters []*HandlerConfig `mapstructure:"authFilters" yaml:"authFilters"`
Decorators []*HandlerConfig `mapstructure:"decorators" yaml:"decorators"`
Endorsers PluginMapping `mapstructure:"endorsers" yaml:"endorsers"`
Validators PluginMapping `mapstructure:"validators" yaml:"validators"`
}
// PluginMapping stores a map between chaincode id to plugin config
type PluginMapping map[string]*HandlerConfig
// HandlerConfig defines configuration for a plugin or compiled handler
type HandlerConfig struct {
Name string `mapstructure:"name" yaml:"name"`
Library string `mapstructure:"library" yaml:"library"`
}
func LoadConfig() (Config, error) {
var authFilters, decorators []*HandlerConfig
if err := mapstructure.Decode(viper.Get("peer.handlers.authFilters"), &authFilters); err != nil {
return Config{}, err
}
if err := mapstructure.Decode(viper.Get("peer.handlers.decorators"), &decorators); err != nil {
return Config{}, err
}
endorsers, validators := make(PluginMapping), make(PluginMapping)
e := viper.GetStringMap("peer.handlers.endorsers")
for k := range e {
name := viper.GetString("peer.handlers.endorsers." + k + ".name")
library := viper.GetString("peer.handlers.endorsers." + k + ".library")
endorsers[k] = &HandlerConfig{Name: name, Library: library}
}
v := viper.GetStringMap("peer.handlers.validators")
for k := range v {
name := viper.GetString("peer.handlers.validators." + k + ".name")
library := viper.GetString("peer.handlers.validators." + k + ".library")
validators[k] = &HandlerConfig{Name: name, Library: library}
}
return Config{
AuthFilters: authFilters,
Decorators: decorators,
Endorsers: endorsers,
Validators: validators,
}, nil
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。