update req package

master
wangyj 6 years ago
parent b38cbcb4af
commit b0df876166

@ -14,8 +14,9 @@ import (
"strings"
"time"
"github.com/franela/goreq"
// "github.com/franela/goreq"
"github.com/goji/httpauth"
"github.com/imroc/req"
"github.com/urfave/cli"
)
@ -91,9 +92,10 @@ func actionStartServer(c *cli.Context) error {
}
func actionStatus(c *cli.Context) error {
res, err := goreq.Request{
Uri: cfg.Client.ServerURL + "/api/programs",
}.Do()
// res, err := goreq.Request{
// Uri: cfg.Client.ServerURL + "/api/programs",
// }.Do()
res, err := req.Get(cfg.Client.ServerURL + "/api/programs")
if err != nil {
return err
}
@ -114,10 +116,12 @@ func actionStatus(c *cli.Context) error {
// cmd: <start|stop>
func programOperate(cmd, name string) (err error, success bool) {
res, err := goreq.Request{
Method: "POST",
Uri: cfg.Client.ServerURL + "/api/programs/" + name + "/" + cmd,
}.Do()
// res, err := goreq.Request{
// Method: "POST",
// Uri: cfg.Client.ServerURL + "/api/programs/" + name + "/" + cmd,
// }.Do()
res, err := req.Post(cfg.Client.ServerURL + "/api/programs/" + name + "/" + cmd)
if err != nil {
return
}

@ -2,7 +2,7 @@ package: github.com/soopsio/gosuv
import:
- package: github.com/soopsio/kexec
- package: github.com/equinox-io/equinox
- package: github.com/franela/goreq
- package: github.com/imroc/req
- package: github.com/glycerine/rbuf
- package: github.com/go-yaml/yaml
- package: github.com/goji/httpauth

@ -11,7 +11,8 @@ import (
"runtime"
"strings"
"github.com/franela/goreq"
// "github.com/franela/goreq"
"github.com/imroc/req"
"github.com/qiniu/log"
"github.com/urfave/cli"
)
@ -31,16 +32,21 @@ type TagInfo struct {
func githubLatestVersion(repo, name string) (tag TagInfo, err error) {
githubURL := fmt.Sprintf("https://api.github.com/repos/%s/%s/releases/latest", repo, name)
req := goreq.Request{Uri: githubURL}
// req := goreq.Request{Uri: githubURL}
r := req.New()
h := req.Header{}
ghToken := os.Getenv("GITHUB_TOKEN")
if ghToken != "" {
req.AddHeader("Authorization", "token "+ghToken)
// req.AddHeader("Authorization", "token "+ghToken)
h["Authorization"] = "token " + ghToken
}
res, err := req.Do()
// res, err := req.Do()
res, err := r.Get(githubURL, h)
if err != nil {
return
}
err = res.Body.FromJsonTo(&tag)
// err = res.Body.FromJsonTo(&tag)
err := res.ToJSON(&tag)
return
}

Loading…
Cancel
Save