Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle / path #26

Merged
merged 1 commit into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"strconv"
"time"

_ "embed"
_ "net/http/pprof"

"github.com/ipfs/boxo/gateway"
Expand All @@ -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 {
Expand Down Expand Up @@ -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
}

Expand Down
56 changes: 56 additions & 0 deletions static/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Welcome to Rainbow IPFS Gateway</title>
<style>
body {
background: linear-gradient(90deg, red, orange, green, blue, indigo, violet);
font-family: Arial, sans-serif;
text-align: center;
color: white;
}
.container {
max-width: 800px;
margin: 0 auto;
padding: 20px;
}
h1 {
font-size: 36px;
}
h2 {
font-size: 36px;
margin-bottom: 50px;
}
p {
font-size: 18px;
margin: 20px 0 40px 0;
}
a {
text-decoration: none;
color: #ffffff;
border: 1px solid #ffffff;
padding: 10px 20px;
border-radius: 5px;
font-size: 16px;
margin: 10px;
transition: background-color 0.3s, border-color 0.3s;
}
a:hover {
background-color: rgba(255, 255, 255, 0.2);
border-color: rgba(255, 255, 255, 0.8);
}
</style>
</head>
<body>
<div class="container">
<h1>Welcome to Rainbow</h1>
<h2>The high performant IPFS Gateway</h2>
<p>Your gateway to a colorful world of decentralized content.</p>
<a href="https://ipfs.tech" target="_blank">Learn about IPFS</a>
<a href="https://github.com/ipfs/rainbow" target="_blank">GitHub Repository</a>
<a href="mailto:[email protected]" target="_blank">Send abuse reports</a>
</div>
</body>
</html>