From 97e6c9a0c2c32bf514d3a4218d239741f1dc26c8 Mon Sep 17 00:00:00 2001 From: bndw Date: Fri, 13 Feb 2026 20:50:27 -0800 Subject: feat: add HTML index page for browser viewing Add a beautiful HTML landing page when visiting relay in browser: - Shows all three protocol endpoints (gRPC, Connect, WebSocket) - Lists supported NIPs (01, 09, 11) - Displays relay features and info - Responsive design with gradient styling - Serves on GET requests (regular Accept header) - NIP-11 still served for Accept: application/nostr+json --- internal/handler/websocket/index.go | 194 ++++++++++++++++++++++++++++++++++++ 1 file changed, 194 insertions(+) create mode 100644 internal/handler/websocket/index.go (limited to 'internal/handler/websocket/index.go') diff --git a/internal/handler/websocket/index.go b/internal/handler/websocket/index.go new file mode 100644 index 0000000..96bcfd4 --- /dev/null +++ b/internal/handler/websocket/index.go @@ -0,0 +1,194 @@ +package websocket + +import ( + "html/template" + "net/http" +) + +var indexTemplate = template.Must(template.New("index").Parse(` + + + + + Nostr gRPC Relay + + + +
+
+

⚡ Nostr gRPC Relay

+

High-performance relay with multi-protocol support

+
+ +
+
+

Protocols

+ +
+

🔌 gRPC (Native Binary)

+

{{.GrpcAddr}}

+

High-performance binary protocol for applications

+
+ +
+

🌐 Connect (HTTP/JSON)

+

{{.HttpAddr}}/nostr.v1.NostrRelay/*

+

Browser-compatible gRPC over HTTP with JSON

+
+ +
+

🔗 WebSocket (Nostr Protocol)

+

ws://{{.WsAddr}}/

+

Standard Nostr protocol (NIP-01) for all clients

+
+
+ +
+

Supported NIPs

+
+ NIP-01 + NIP-09 + NIP-11 +
+
+ +
+

Features

+
    +
  • Binary-first storage (Protocol Buffers)
  • +
  • SQLite with WAL mode
  • +
  • Event validation (ID & signature)
  • +
  • Real-time subscriptions
  • +
  • Event deletion (NIP-09)
  • +
+
+
+ + +
+ +`)) + +type IndexData struct { + GrpcAddr string + HttpAddr string + WsAddr string +} + +func (h *Handler) ServeIndex(w http.ResponseWriter, r *http.Request, data IndexData) { + w.Header().Set("Content-Type", "text/html; charset=utf-8") + indexTemplate.Execute(w, data) +} -- cgit v1.2.3