committed by
GitHub
parent
ce5dd1aaa2
commit
27c54b4739
@@ -3,21 +3,9 @@ package main
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func (c *Client) Approve() (string, int, error) {
|
||||
|
||||
_, res, err := c.git.MergeRequestApprovals.ApproveMergeRequest(c.projectId, c.mergeId, nil, nil)
|
||||
|
||||
if err != nil {
|
||||
return "", res.Response.StatusCode, fmt.Errorf("Approving MR failed: %w", err)
|
||||
}
|
||||
|
||||
return "Success! Approved MR.", http.StatusOK, nil
|
||||
}
|
||||
|
||||
func ApproveHandler(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
c := r.Context().Value("client").(Client)
|
||||
@@ -26,7 +14,8 @@ func ApproveHandler(w http.ResponseWriter, r *http.Request) {
|
||||
c.handleError(w, errors.New("Invalid request type"), "That request type is not allowed", http.StatusMethodNotAllowed)
|
||||
return
|
||||
}
|
||||
msg, status, err := c.Approve()
|
||||
|
||||
_, res, err := c.git.MergeRequestApprovals.ApproveMergeRequest(c.projectId, c.mergeId, nil, nil)
|
||||
|
||||
if err != nil {
|
||||
c.handleError(w, err, "Could not approve MR", http.StatusBadRequest)
|
||||
@@ -34,9 +23,9 @@ func ApproveHandler(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
/* TODO: Check for non-200 status codes */
|
||||
w.WriteHeader(status)
|
||||
w.WriteHeader(res.StatusCode)
|
||||
response := SuccessResponse{
|
||||
Message: msg,
|
||||
Message: "Success! Approved MR.",
|
||||
Status: http.StatusOK,
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user