提交 f39f3fe4 作者: Matt Bell

cmd/ipfs: Redirect requests to /webui to webui app

上级 b5300f1d
......@@ -24,7 +24,10 @@ const (
ipnsMountKwd = "mount-ipns"
// apiAddrKwd = "address-api"
// swarmAddrKwd = "address-swarm"
originEnvKey = "API_ORIGIN"
webuiPath = "/ipfs/QmTWvqK9dYvqjAMAcCeUun8b45Fwu7wPhEN9B9TsGbkXfJ"
)
var daemonCmd = &cmds.Command{
......@@ -171,6 +174,7 @@ func listenAndServeAPI(node *core.IpfsNode, req cmds.Request, addr ma.Multiaddr)
}
mux.Handle("/ipfs/", gateway)
mux.Handle("/webui/", &redirectHandler{webuiPath})
// if the server exits beforehand
var serverError error
......@@ -238,3 +242,11 @@ func listenAndServeGateway(node *core.IpfsNode, addr ma.Multiaddr) error {
return nil
}
type redirectHandler struct {
path string
}
func (i *redirectHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
http.Redirect(w, r, i.path, 302)
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论