From f39f3fe43256f6fc2c5659a359bd0426e1bbdb7a Mon Sep 17 00:00:00 2001 From: Matt Bell Date: Sun, 11 Jan 2015 22:01:53 -0800 Subject: [PATCH] cmd/ipfs: Redirect requests to /webui to webui app --- cmd/ipfs/daemon.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/cmd/ipfs/daemon.go b/cmd/ipfs/daemon.go index c2bb740bb..9999cb9f6 100644 --- a/cmd/ipfs/daemon.go +++ b/cmd/ipfs/daemon.go @@ -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) +}