提交 1d01c035 作者: Brian Tiger Chow

refactor(cmd/daemon) more compact representation!

exposed the Decider to make configuration nicer @mappum
上级 db644fe1
...@@ -193,19 +193,19 @@ func daemonFunc(req cmds.Request, res cmds.Response) { ...@@ -193,19 +193,19 @@ func daemonFunc(req cmds.Request, res cmds.Response) {
}() }()
} }
blocklist := &corehttp.BlockList{}
blocklist.SetDecider(func(s string) bool {
// for now, only allow paths in the WebUI path
for _, webuipath := range corehttp.WebUIPaths {
if strings.HasPrefix(s, webuipath) {
return true
}
}
return false
})
gateway := corehttp.NewGateway(corehttp.GatewayConfig{ gateway := corehttp.NewGateway(corehttp.GatewayConfig{
Writable: true, Writable: true,
BlockList: blocklist, BlockList: &corehttp.BlockList{
Decider: func(s string) bool {
// for now, only allow paths in the WebUI path
for _, webuipath := range corehttp.WebUIPaths {
if strings.HasPrefix(s, webuipath) {
return true
}
}
return false
},
},
}) })
var opts = []corehttp.ServeOption{ var opts = []corehttp.ServeOption{
corehttp.CommandsOption(*req.Context()), corehttp.CommandsOption(*req.Context()),
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论