From 520be2359bd35c0c1390c4964ebe4055b8e071f8 Mon Sep 17 00:00:00 2001 From: Hector Sanjuan Date: Mon, 16 Oct 2023 17:40:45 +0200 Subject: [PATCH] Fix handling of default url --- Dockerfile | 2 +- handlers.go | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index 397afc3..8e26cbb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -32,7 +32,7 @@ FROM alpine:3.18 # This runs rainbow # Instal binaries for $TARGETARCH -RUN apk add --no-cache tini su-exec ca-certificates +RUN apk add --no-cache tini su-exec ca-certificates curl ENV GOPATH /go ENV SRC_PATH $GOPATH/src/github.com/ipfs/rainbow diff --git a/handlers.go b/handlers.go index 06e1226..ef92d5e 100644 --- a/handlers.go +++ b/handlers.go @@ -154,6 +154,9 @@ func setupGatewayHandler(nd *Node) (http.Handler, error) { // allows us to decide when is the time to do it. legacyKuboRPCHandler := withHTTPMetrics(newKuboRPCHandler(nd.kuboRPCs), "legacyKuboRpc") topMux.Handle("/api/v0/", legacyKuboRPCHandler) + topMux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + w.Write(indexHTML) + }) // Construct the HTTP handler for the gateway. handler := withConnect(topMux) @@ -244,16 +247,12 @@ func newKuboRPCHandler(endpoints []string) http.Handler { mux.HandleFunc("/api/v0/dns", redirectToKubo) // Remaining requests to the API receive a 501, as well as an explanation. - mux.HandleFunc("/api/", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/api/v0/", func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusNotImplemented) goLog.Debugw("api request returned 501", "url", r.URL) w.Write([]byte("The /api/v0 Kubo RPC is now discontinued on this server as it is not part of the gateway specification. If you need this API, please self-host a Kubo instance yourself: https://docs.ipfs.tech/install/command-line/")) }) - mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { - w.Write(indexHTML) - }) - return mux }