(resp http.ResponseWriter, request *http.Request, reqPath string, state htmlState)
| 332 | } |
| 333 | |
| 334 | func (h *Handler) serveHTML(resp http.ResponseWriter, request *http.Request, reqPath string, state htmlState) bool { |
| 335 | if data, err := h.renderHTMLWithState(request, reqPath, state); err == nil { |
| 336 | if reqPath == "" { |
| 337 | // Pass "index.html" to the ServeContent so the ServeContent sets the right content headers. |
| 338 | reqPath = "index.html" |
| 339 | } |
| 340 | // `Once` is used to reduce the volume of db calls and telemetry reports. |
| 341 | // It's fine to run the enclosed function multiple times, but it's unnecessary. |
| 342 | h.telemetryHTMLServedOnce.Do(func() { |
| 343 | go h.reportHTMLFirstServedAt() |
| 344 | }) |
| 345 | http.ServeContent(resp, request, reqPath, time.Time{}, bytes.NewReader(data)) |
| 346 | return true |
| 347 | } |
| 348 | return false |
| 349 | } |
| 350 | |
| 351 | func execTmpl(tmpl *template.Template, state htmlState) ([]byte, error) { |
| 352 | var buf bytes.Buffer |
no test coverage detected