MCPcopy
hub / github.com/harness/harness / HandleCommentCreate

Function HandleCommentCreate

app/api/handler/pullreq/comment_create.go:27–59  ·  view source on GitHub ↗

HandleCommentCreate is an HTTP handler for creating a new pull request comment or a reply to a comment.

(pullreqCtrl *pullreq.Controller)

Source from the content-addressed store, hash-verified

25
26// HandleCommentCreate is an HTTP handler for creating a new pull request comment or a reply to a comment.
27func HandleCommentCreate(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 in := new(pullreq.CommentCreateInput)
45 err = json.NewDecoder(r.Body).Decode(in)
46 if err != nil {
47 render.BadRequestf(ctx, w, "Invalid Request Body: %s.", err)
48 return
49 }
50
51 comment, err := pullreqCtrl.CommentCreate(ctx, session, repoRef, pullreqNumber, in)
52 if err != nil {
53 render.TranslatedUserError(ctx, w, err)
54 return
55 }
56
57 render.JSON(w, http.StatusCreated, comment)
58 }
59}

Callers

nothing calls this directly

Calls 8

AuthSessionFromFunction · 0.92
GetRepoRefFromPathFunction · 0.92
TranslatedUserErrorFunction · 0.92
GetPullReqNumberFromPathFunction · 0.92
BadRequestfFunction · 0.92
JSONFunction · 0.92
DecodeMethod · 0.65
CommentCreateMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…