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

Function alterHandler

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

Source from the content-addressed store, hash-verified

625}
626
627func alterHandler(w http.ResponseWriter, r *http.Request) {
628 if commonHandler(w, r) {
629 return
630 }
631
632 b := readRequest(w, r)
633 if b == nil {
634 return
635 }
636
637 op := &api.Operation{}
638 if err := jsonpb.Unmarshal(b, op); err != nil {
639 op.Schema = string(b)
640 }
641
642 runInBackground, err := parseBool(r, "runInBackground")
643 if err != nil {
644 x.SetStatus(w, x.ErrorInvalidRequest, err.Error())
645 return
646 }
647 op.RunInBackground = runInBackground
648
649 glog.Infof("Got alter request via HTTP from %s\n", r.RemoteAddr)
650 fwd := r.Header.Get("X-Forwarded-For")
651 if len(fwd) > 0 {
652 glog.Infof("The alter request is forwarded by %s\n", fwd)
653 }
654
655 // Pass in PoorMan's auth, ACL and IP information if present.
656 ctx := x.AttachAuthToken(context.Background(), r)
657 ctx = x.AttachAccessJwt(ctx, r)
658 ctx = x.AttachRemoteIP(ctx, r)
659 if _, err := (&edgraph.Server{}).Alter(ctx, op); err != nil {
660 x.SetStatus(w, x.Error, err.Error())
661 return
662 }
663
664 writeSuccessResponse(w, r)
665}
666
667func adminSchemaHandler(w http.ResponseWriter, r *http.Request) {
668 if commonHandler(w, r) {

Callers

nothing calls this directly

Calls 12

SetStatusFunction · 0.92
AttachAuthTokenFunction · 0.92
AttachAccessJwtFunction · 0.92
AttachRemoteIPFunction · 0.92
commonHandlerFunction · 0.85
readRequestFunction · 0.85
parseBoolFunction · 0.85
writeSuccessResponseFunction · 0.85
InfofMethod · 0.80
AlterMethod · 0.80
GetMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected