Commit 9148e34
pkg/gitlab/client.go
@@ -33,9 +33,18 @@ func (gl *GitLab) Group(id int) *Group {
}
func (gl *GitLab) Get(url string) *http.Response {
+ return gl.execute(gl.newRequest("GET", url))
+}
+
+func (gl *GitLab) newRequest(method string, url string) *http.Request {
request := x.Must(http.NewRequestWithContext(gl.ctx, "GET", url, nil))
request.Header.Add("Authorization", fmt.Sprintf("Bearer %v", gl.token))
+ return request
+}
+
+func (gl *GitLab) execute(request *http.Request) *http.Response {
response := x.Must(gl.client.Do(request))
+
if env.Fetch("DUMP", "") != "" {
body := x.Must(io.ReadAll(response.Body))
fmt.Println(string(body))
pkg/gitlab/group.go
@@ -7,21 +7,21 @@ import (
)
type Group struct {
- client *GitLab
- id int
- url string
+ api *GitLab
+ id int
+ url string
}
func NewGroup(gl *GitLab, id int) *Group {
return &Group{
- client: gl,
- id: id,
- url: fmt.Sprintf("%v/groups/%v", gl.url, id),
+ api: gl,
+ id: id,
+ url: fmt.Sprintf("%v/groups/%v", gl.url, id),
}
}
func (group *Group) Issues() []Issue {
- response := group.client.Get(group.url + "/issues")
+ response := group.api.Get(group.url + "/issues")
defer response.Body.Close()
return x.Must(FromIssues(response.Body))