MCPcopy Index your code
hub / github.com/subtrace/subtrace / html

Method html

devtools/devtools.go:172–204  ·  view source on GitHub ↗
(w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

170}
171
172func (s *Server) html(w http.ResponseWriter, r *http.Request) {
173 w.Header().Set("content-type", "text/html; charset=utf-8")
174 w.Header().Set("cache-control", "max-age=3600")
175 w.Header().Set("cross-origin-opener-policy", "same-origin")
176 w.Header().Set("cross-origin-embedder-policy", "require-corp")
177 w.Header().Set("connection", "close")
178
179 accept := make(map[string]bool)
180 for _, val := range strings.Split(r.Header.Get("accept-encoding"), ",") {
181 val = strings.TrimSpace(val)
182 if val == "" {
183 continue
184 }
185 accept[val] = true
186 }
187
188 var body io.Writer = w
189 switch {
190 case accept["br"]:
191 w.Header().Set("content-encoding", "br")
192 bw := brotli.NewWriter(w)
193 defer bw.Close()
194 body = bw
195 case accept["gzip"]:
196 w.Header().Set("content-encoding", "gzip")
197 gw := gzip.NewWriter(w)
198 defer gw.Close()
199 body = gw
200 }
201
202 bundleOnce()
203 body.Write(html)
204}
205
206func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
207 if r.Header.Get("upgrade") == "websocket" {

Callers 1

ServeHTTPMethod · 0.95

Calls 6

bundleOnceFunction · 0.85
HeaderMethod · 0.80
WriteMethod · 0.80
SetMethod · 0.45
GetMethod · 0.45
CloseMethod · 0.45

Tested by

no test coverage detected