HandleCommentUpdate is an HTTP handler for updating a pull request comment.
(pullreqCtrl *pullreq.Controller)
| 25 | |
| 26 | // HandleCommentUpdate is an HTTP handler for updating a pull request comment. |
| 27 | func HandleCommentUpdate(pullreqCtrl *pullreq.Controller) http.HandlerFunc { |
| 28 | return func(w http.ResponseWriter, r *http.Request) { |
| 29 | ctx := r.Context() |
| 30 | session, _ := request.AuthSessionFrom(ctx) |
| 31 | |
| 32 | repoRef, err := request.GetRepoRefFromPath(r) |
| 33 | if err != nil { |
| 34 | render.TranslatedUserError(ctx, w, err) |
| 35 | return |
| 36 | } |
| 37 | |
| 38 | pullreqNumber, err := request.GetPullReqNumberFromPath(r) |
| 39 | if err != nil { |
| 40 | render.TranslatedUserError(ctx, w, err) |
| 41 | return |
| 42 | } |
| 43 | |
| 44 | commentID, err := request.GetPullReqCommentIDPath(r) |
| 45 | if err != nil { |
| 46 | render.TranslatedUserError(ctx, w, err) |
| 47 | return |
| 48 | } |
| 49 | |
| 50 | in := new(pullreq.CommentUpdateInput) |
| 51 | err = json.NewDecoder(r.Body).Decode(in) |
| 52 | if err != nil { |
| 53 | render.BadRequestf(ctx, w, "Invalid Request Body: %s.", err) |
| 54 | return |
| 55 | } |
| 56 | |
| 57 | comment, err := pullreqCtrl.CommentUpdate(ctx, session, repoRef, pullreqNumber, commentID, in) |
| 58 | if err != nil { |
| 59 | render.TranslatedUserError(ctx, w, err) |
| 60 | return |
| 61 | } |
| 62 | |
| 63 | render.JSON(w, http.StatusOK, comment) |
| 64 | } |
| 65 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…