Complete create-jira-ticket command
This commit is contained in:
parent
fa5f07d3db
commit
5d727b8995
3 changed files with 90 additions and 18 deletions
26
http/http.go
Normal file
26
http/http.go
Normal 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)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue