From ec58accdd70f6f7976ccaa588a6463030baa2051 Mon Sep 17 00:00:00 2001 From: Hector Sanjuan Date: Mon, 16 Oct 2023 16:21:12 +0200 Subject: [PATCH] Handle / path Fixes #18 --- handlers.go | 10 ++++++++- static/index.html | 56 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 static/index.html diff --git a/handlers.go b/handlers.go index 8a4c59c..06e1226 100644 --- a/handlers.go +++ b/handlers.go @@ -10,6 +10,7 @@ import ( "strconv" "time" + _ "embed" _ "net/http/pprof" "github.com/ipfs/boxo/gateway" @@ -20,6 +21,9 @@ import ( "go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp" ) +//go:embed static/index.html +var indexHTML []byte + const DefaultKuboRPC = "http://127.0.0.1:5001" func makeMetricsAndDebuggingHandler() *http.ServeMux { @@ -240,12 +244,16 @@ 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("/", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/api/", 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 } diff --git a/static/index.html b/static/index.html new file mode 100644 index 0000000..8c633bd --- /dev/null +++ b/static/index.html @@ -0,0 +1,56 @@ + + + + + + Welcome to Rainbow IPFS Gateway + + + +
+

Welcome to Rainbow

+

The high performant IPFS Gateway

+

Your gateway to a colorful world of decentralized content.

+ Learn about IPFS + GitHub Repository + Send abuse reports +
+ +