This MR adds linting and formatting to the CI pipeline for the repository for both the Golang and Lua code.
45 lines
1.0 KiB
Go
45 lines
1.0 KiB
Go
package main
|
|
|
|
import (
|
|
"encoding/json"
|
|
"net/http"
|
|
|
|
"github.com/xanzy/go-gitlab"
|
|
)
|
|
|
|
type ProjectMembersResponse struct {
|
|
SuccessResponse
|
|
ProjectMembers []*gitlab.ProjectMember
|
|
}
|
|
|
|
func ProjectMembersHandler(w http.ResponseWriter, r *http.Request) {
|
|
c := r.Context().Value("client").(Client)
|
|
w.Header().Set("Content-Type", "application/json")
|
|
|
|
projectMemberOptions := gitlab.ListProjectMembersOptions{
|
|
ListOptions: gitlab.ListOptions{
|
|
PerPage: 100,
|
|
},
|
|
}
|
|
|
|
projectMembers, res, err := c.git.ProjectMembers.ListAllProjectMembers(c.projectId, &projectMemberOptions)
|
|
if err != nil {
|
|
c.handleError(w, err, "Could not fetch project users", res.StatusCode)
|
|
}
|
|
|
|
w.WriteHeader(http.StatusOK)
|
|
|
|
response := ProjectMembersResponse{
|
|
SuccessResponse: SuccessResponse{
|
|
Status: http.StatusOK,
|
|
Message: "Project users fetched successfully",
|
|
},
|
|
ProjectMembers: projectMembers,
|
|
}
|
|
|
|
err = json.NewEncoder(w).Encode(response)
|
|
if err != nil {
|
|
c.handleError(w, err, "Could not encode response", http.StatusInternalServerError)
|
|
}
|
|
}
|