Skip to content

Commit

Permalink
Fix handling of default url
Browse files Browse the repository at this point in the history
  • Loading branch information
hsanjuan committed Oct 16, 2023
1 parent 7b5f9f7 commit 520be23
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 4 additions & 5 deletions handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit 520be23

Please sign in to comment.