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

This commit is contained in:
Matt Bell 2015-01-11 22:01:53 -08:00
parent b5300f1d27
commit f39f3fe432

View File

@ -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)
}