代码拉取完成,页面将自动刷新
// Package whitelist is a micro plugin for whitelisting service requests
package whitelist
import (
"net/http"
"strings"
"github.com/micro/cli"
"github.com/micro/go-micro/client"
"github.com/micro/micro/plugin"
)
type whitelist struct {
services map[string]bool
}
func (w *whitelist) Flags() []cli.Flag {
return []cli.Flag{
cli.StringFlag{
Name: "rpc_whitelist",
Usage: "Comma separated whitelist of allowed services for RPC calls",
EnvVar: "RPC_WHITELIST",
},
}
}
func (w *whitelist) Commands() []cli.Command {
return nil
}
func (w *whitelist) Handler() plugin.Handler {
return func(h http.Handler) http.Handler {
return h
}
}
func (w *whitelist) Init(ctx *cli.Context) error {
if whitelist := ctx.String("rpc_whitelist"); len(whitelist) > 0 {
client.DefaultClient = newClient(strings.Split(whitelist, ",")...)
}
return nil
}
func (w *whitelist) String() string {
return "whitelist"
}
func NewRPCWhitelist(services ...string) plugin.Plugin {
list := make(map[string]bool)
for _, service := range services {
list[service] = true
}
return &whitelist{
services: list,
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。