(w http.ResponseWriter, r *http.Request)
| 625 | } |
| 626 | |
| 627 | func 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 | |
| 667 | func adminSchemaHandler(w http.ResponseWriter, r *http.Request) { |
| 668 | if commonHandler(w, r) { |
nothing calls this directly
no test coverage detected