MCPcopy Index your code
hub / github.com/coder/coder / serveHTML

Method serveHTML

site/site.go:334–349  ·  view source on GitHub ↗
(resp http.ResponseWriter, request *http.Request, reqPath string, state htmlState)

Source from the content-addressed store, hash-verified

332}
333
334func (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
351func execTmpl(tmpl *template.Template, state htmlState) ([]byte, error) {
352 var buf bytes.Buffer

Callers 1

ServeHTTPMethod · 0.95

Implementers 8

dispatchInterceptorcoderd/notifications/utils_test.go
chanHandlercoderd/notifications/utils_test.go
barrierHandlercoderd/notifications/metrics_test.go
fakeHandlercoderd/notifications/notifications_tes
santaHandlercoderd/notifications/manager_test.go
InboxHandlercoderd/notifications/dispatch/inbox.go
SMTPHandlercoderd/notifications/dispatch/smtp.go
WebhookHandlercoderd/notifications/dispatch/webhook.

Calls 3

renderHTMLWithStateMethod · 0.95
DoMethod · 0.65

Tested by

no test coverage detected