@cryptotaxi247 / kubo / commits / f39f3fe43

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

Matt Bell committed Jan 11, 2015 at 22:01 UTC f39f3fe43256f6fc2c5659a359bd0426e1bbdb7a
1 file changed +12
cmd/ipfs/daemon.go
+12
@@ -24,7 +24,10 @@ const (
24 ipnsMountKwd = "mount-ipns"
25 // apiAddrKwd = "address-api"
26 // swarmAddrKwd = "address-swarm"
27 +
28 originEnvKey = "API_ORIGIN"
29 +
30 + webuiPath = "/ipfs/QmTWvqK9dYvqjAMAcCeUun8b45Fwu7wPhEN9B9TsGbkXfJ"
31 )
32
33 var daemonCmd = &cmds.Command{
@@ -171,6 +174,7 @@ func listenAndServeAPI(node *core.IpfsNode, req cmds.Request, addr ma.Multiaddr)
174 }
175
176 mux.Handle("/ipfs/", gateway)
177 + mux.Handle("/webui/", &redirectHandler{webuiPath})
178
179 // if the server exits beforehand
180 var serverError error
@@ -238,3 +242,11 @@ func listenAndServeGateway(node *core.IpfsNode, addr ma.Multiaddr) error {
242
243 return nil
244 }
245 +
246 +type redirectHandler struct {
247 + path string
248 +}
249 +
250 +func (i *redirectHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
251 + http.Redirect(w, r, i.path, 302)
252 +}