diff options
| author | mo khan <mo@mokhan.ca> | 2024-05-18 11:26:42 -0600 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2024-05-18 11:26:42 -0600 |
| commit | 250ceb538b6bacea5cb0ee4c830ac6f5c03fbf6b (patch) | |
| tree | 088b6a30eba4c8f785e571d2efdb66e6f0b2cd3d /cmd | |
| parent | 56cee5390c71cd31bda902aa1ca484b13757a4b5 (diff) | |
feat: build request to REST API
Diffstat (limited to 'cmd')
| -rw-r--r-- | cmd/stanuki/main.go | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/cmd/stanuki/main.go b/cmd/stanuki/main.go index bd6e00f..ea7c5d2 100644 --- a/cmd/stanuki/main.go +++ b/cmd/stanuki/main.go @@ -1,7 +1,26 @@ package main -import "fmt" +import ( + "context" + "fmt" + "io" + "net/http" + + "github.com/xlgmokha/x/pkg/env" + "github.com/xlgmokha/x/pkg/x" +) func main() { - fmt.Println("Hello, Stanuki!") + token := env.Fetch("GITLAB_TOKEN", "") + url := "https://gitlab.com/api/v4/groups/4/issues" + client := http.Client{} + request := x.Must(http.NewRequestWithContext(context.TODO(), "GET", url, nil)) + request.Header.Add("Authorization", fmt.Sprintf("Bearer %v", token)) + response := x.Must(client.Do(request)) + + if response.StatusCode == http.StatusOK { + } else { + fmt.Println(response.Status) + fmt.Println(string(x.Must(io.ReadAll(response.Body)))) + } } |
