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

Function WriteIndent

coderd/httpapi/httpapi.go:214–230  ·  view source on GitHub ↗
(ctx context.Context, rw http.ResponseWriter, status int, response interface{})

Source from the content-addressed store, hash-verified

212}
213
214func WriteIndent(ctx context.Context, rw http.ResponseWriter, status int, response interface{}) {
215 _, span := tracing.StartSpan(ctx)
216 defer span.End()
217
218 SetAuthzCheckRecorderHeader(ctx, rw)
219
220 rw.Header().Set("Content-Type", "application/json; charset=utf-8")
221 rw.WriteHeader(status)
222
223 enc := json.NewEncoder(rw)
224 enc.SetEscapeHTML(true)
225 enc.SetIndent("", "\t")
226
227 // We can't really do much about these errors, it's probably due to a
228 // dropped connection.
229 _ = enc.Encode(response)
230}
231
232// Read decodes JSON from the HTTP request into the value provided. It uses
233// go-validator to validate the incoming request body. ctx is used for tracing

Callers 2

formatHealthcheckFunction · 0.92
WriteFunction · 0.85

Calls 6

StartSpanFunction · 0.92
EncodeMethod · 0.80
SetMethod · 0.65
HeaderMethod · 0.45
WriteHeaderMethod · 0.45

Tested by

no test coverage detected