Complete create-jira-ticket command

This commit is contained in:
Miguel de la Cruz 2020-03-01 12:30:49 +01:00
parent fa5f07d3db
commit 5d727b8995
3 changed files with 90 additions and 18 deletions

26
http/http.go Normal file
View file

@ -0,0 +1,26 @@
package http
import (
"bytes"
"net/http"
)
func Do(method, username, token, url string, body []byte) (*http.Response, error) {
req, err := http.NewRequest("POST", url, bytes.NewBuffer(body))
if err != nil {
return nil, err
}
req.SetBasicAuth(username, token)
req.Header.Add("Content-Type", "application/json")
client := http.Client{}
return client.Do(req)
}
func DoGet(username, token, url string) (*http.Response, error) {
return Do("GET", username, token, url, []byte{})
}
func DoPost(username, token, url string, body []byte) (*http.Response, error) {
return Do("POST", username, token, url, body)
}