diff options
| -rw-r--r-- | cmd/stanuki/main.go | 23 | ||||
| -rw-r--r-- | go.mod | 2 | ||||
| -rw-r--r-- | go.sum | 2 |
3 files changed, 25 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)))) + } } @@ -1,3 +1,5 @@ module gitlab.com/mokhax/stanuki go 1.22 + +require github.com/xlgmokha/x v0.0.0-20221023040112-0610463739d1 // indirect @@ -0,0 +1,2 @@ +github.com/xlgmokha/x v0.0.0-20221023040112-0610463739d1 h1:MIqcDqEAcr16QUq/kFJC3xbYoaAjjsxYEJLGtol2U58= +github.com/xlgmokha/x v0.0.0-20221023040112-0610463739d1/go.mod h1:Hf/0a9FveTBuVKvZ+Emmw6BlJyLGlhgjQwa4dFXp48s= |
