MCPcopy
hub / github.com/dgraph-io/dgraph / stateHandler

Function stateHandler

dgraph/cmd/alpha/run.go:419–441  ·  view source on GitHub ↗
(w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

417}
418
419func stateHandler(w http.ResponseWriter, r *http.Request) {
420 var err error
421 x.AddCorsHeaders(w)
422 w.Header().Set("Content-Type", "application/json")
423
424 ctx := context.Background()
425 ctx = x.AttachAccessJwt(ctx, r)
426
427 var aResp *api.Response
428 if aResp, err = (&edgraph.Server{}).State(ctx); err != nil {
429 x.SetStatus(w, x.Error, err.Error())
430 return
431 }
432 if aResp == nil {
433 x.SetStatus(w, x.ErrorNoData, "No state information available.")
434 return
435 }
436
437 if _, err = w.Write(aResp.Json); err != nil {
438 x.SetStatus(w, x.Error, err.Error())
439 return
440 }
441}
442
443// storeStatsHandler outputs some basic stats for data store.
444func storeStatsHandler(w http.ResponseWriter, r *http.Request) {

Callers

nothing calls this directly

Calls 7

AddCorsHeadersFunction · 0.92
AttachAccessJwtFunction · 0.92
SetStatusFunction · 0.92
StateMethod · 0.80
SetMethod · 0.65
WriteMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected