(w http.ResponseWriter, r *http.Request)
| 508 | } |
| 509 | |
| 510 | func commitHandler(w http.ResponseWriter, r *http.Request) { |
| 511 | if commonHandler(w, r) { |
| 512 | return |
| 513 | } |
| 514 | |
| 515 | startTs, err := parseUint64(r, "startTs") |
| 516 | if err != nil { |
| 517 | x.SetStatus(w, x.ErrorInvalidRequest, err.Error()) |
| 518 | return |
| 519 | } |
| 520 | if startTs == 0 { |
| 521 | x.SetStatus(w, x.ErrorInvalidRequest, |
| 522 | "startTs parameter is mandatory while trying to commit") |
| 523 | return |
| 524 | } |
| 525 | |
| 526 | hash := r.URL.Query().Get("hash") |
| 527 | abort, err := parseBool(r, "abort") |
| 528 | if err != nil { |
| 529 | x.SetStatus(w, x.ErrorInvalidRequest, err.Error()) |
| 530 | return |
| 531 | } |
| 532 | |
| 533 | ctx := x.AttachAccessJwt(context.Background(), r) |
| 534 | var response map[string]interface{} |
| 535 | if abort { |
| 536 | response, err = handleAbort(ctx, startTs, hash) |
| 537 | } else { |
| 538 | // Keys are sent as an array in the body. |
| 539 | reqText := readRequest(w, r) |
| 540 | if reqText == nil { |
| 541 | return |
| 542 | } |
| 543 | |
| 544 | response, err = handleCommit(ctx, startTs, hash, reqText) |
| 545 | } |
| 546 | if err != nil { |
| 547 | x.SetStatus(w, x.ErrorInvalidRequest, err.Error()) |
| 548 | return |
| 549 | } |
| 550 | |
| 551 | js, err := json.Marshal(response) |
| 552 | if err != nil { |
| 553 | x.SetStatusWithData(w, x.Error, err.Error()) |
| 554 | return |
| 555 | } |
| 556 | |
| 557 | _, _ = x.WriteResponse(w, r, js) |
| 558 | } |
| 559 | |
| 560 | func handleAbort(ctx context.Context, startTs uint64, hash string) (map[string]interface{}, error) { |
| 561 | tc := &api.TxnContext{ |
nothing calls this directly
no test coverage detected