提交 7c5b2761 作者: Matt Bell 提交者: Juan Batiz-Benet

cmd/ipfs: daemon: Added root redirect handler to corehttp options (for both gateway and API)

上级 47774c53
......@@ -153,9 +153,18 @@ func daemonFunc(req cmds.Request, res cmds.Response) {
fmt.Printf("IPNS mounted at: %s\n", nsdir)
}
var rootRedirect corehttp.ServeOption
if len(cfg.Gateway.RootRedirect) > 0 {
rootRedirect = corehttp.RedirectOption("", cfg.Gateway.RootRedirect)
}
if gatewayMaddr != nil {
go func() {
err := corehttp.ListenAndServe(node, gatewayMaddr.String(), corehttp.GatewayOption)
var opts = []corehttp.ServeOption{corehttp.GatewayOption}
if rootRedirect != nil {
opts = append(opts, rootRedirect)
}
err := corehttp.ListenAndServe(node, gatewayMaddr.String(), opts...)
if err != nil {
log.Error(err)
}
......@@ -167,6 +176,9 @@ func daemonFunc(req cmds.Request, res cmds.Response) {
corehttp.WebUIOption,
corehttp.GatewayOption,
}
if rootRedirect != nil {
opts = append(opts, rootRedirect)
}
if err := corehttp.ListenAndServe(node, apiMaddr.String(), opts...); err != nil {
res.SetError(err, cmds.ErrNormal)
return
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论