Skip to content

Commit

Permalink
Merge pull request #26 from ipfs/frontpage
Browse files Browse the repository at this point in the history
Handle / path
  • Loading branch information
hsanjuan authored Oct 16, 2023
2 parents 38fef5d + ec58acc commit f4bc5b2
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 1 deletion.
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>

0 comments on commit f4bc5b2

Please sign in to comment.