-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhome.go
More file actions
27 lines (22 loc) · 813 Bytes
/
home.go
File metadata and controls
27 lines (22 loc) · 813 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package peerdb
import (
"net/http"
"gitlab.com/tozd/waf"
)
// HomeGet is a GET/HEAD HTTP request handler which returns HTML frontend for the home page.
func (s *Service) HomeGet(w http.ResponseWriter, req *http.Request, _ waf.Params) {
// During development Vite creates WebSocket connection. We always proxy it.
if s.ProxyStaticTo != "" && hasConnectionUpgrade(req) {
s.Proxy(w, req)
return
}
// We have it hard-coded here because we have it hard-coded on the frontend as well.
w.Header().Add("Link", "</context.json>; rel=preload; as=fetch; crossorigin=anonymous")
w.Header().Add("Link", "</routes.json>; rel=preload; as=fetch; crossorigin=anonymous")
w.WriteHeader(http.StatusEarlyHints)
if s.ProxyStaticTo != "" {
s.Proxy(w, req)
} else {
s.ServeStaticFile(w, req, "/index.html")
}
}