Commit c66ef25b authored by ibuler's avatar ibuler

[Update] Merge master to local master (conflict: pkg/sdk/client.go)

parents 834a0e68 22805668
...@@ -13,9 +13,10 @@ type ClientAuth interface { ...@@ -13,9 +13,10 @@ type ClientAuth interface {
} }
type WrapperClient struct { type WrapperClient struct {
Http *common.Client Http *common.Client
Auth ClientAuth AuthClient *common.Client
BaseHost string Auth ClientAuth
BaseHost string
} }
func (c *WrapperClient) LoadAuth() error { func (c *WrapperClient) LoadAuth() error {
...@@ -42,16 +43,24 @@ func (c *WrapperClient) CheckAuth() error { ...@@ -42,16 +43,24 @@ func (c *WrapperClient) CheckAuth() error {
} }
func (c *WrapperClient) Get(url string, res interface{}, needAuth bool) error { func (c *WrapperClient) Get(url string, res interface{}, needAuth bool) error {
<<<<<<< HEAD
//if needAuth { //if needAuth {
// c.Http.SetAuth(c.Auth.Sign()) // c.Http.SetAuth(c.Auth.Sign())
//} else { //} else {
// c.Http.SetAuth("") // c.Http.SetAuth("")
//} //}
=======
if needAuth {
return c.AuthClient.Get(c.BaseHost+url, res)
} else {
return c.Http.Get(c.BaseHost+url, res)
}
>>>>>>> 228056688660034ec5b8061e99c187aa0b1c85e7
return c.Http.Get(c.BaseHost+url, res)
} }
func (c *WrapperClient) Post(url string, data interface{}, res interface{}, needAuth bool) error { func (c *WrapperClient) Post(url string, data interface{}, res interface{}, needAuth bool) error {
<<<<<<< HEAD
//if needAuth { //if needAuth {
// c.Http.SetAuth(c.Auth.Sign()) // c.Http.SetAuth(c.Auth.Sign())
//} else { //} else {
...@@ -85,4 +94,35 @@ func (c *WrapperClient) Patch(url string, data interface{}, res interface{}, nee ...@@ -85,4 +94,35 @@ func (c *WrapperClient) Patch(url string, data interface{}, res interface{}, nee
// c.Http.SetAuth("") // c.Http.SetAuth("")
//} //}
return c.Http.Patch(url, data, res) return c.Http.Patch(url, data, res)
=======
if needAuth {
return c.AuthClient.Post(url, data, res)
} else {
return c.Http.Post(url, data, res)
}
}
func (c *WrapperClient) Delete(url string, res interface{}, needAuth bool) error {
if needAuth {
return c.AuthClient.Delete(url, res)
} else {
return c.Http.Delete(url, res)
}
}
func (c *WrapperClient) Put(url string, data interface{}, res interface{}, needAuth bool) error {
if needAuth {
return c.AuthClient.Put(url, data, res)
} else {
return c.Http.Put(url, data, res)
}
}
func (c *WrapperClient) Patch(url string, data interface{}, res interface{}, needAuth bool) error {
if needAuth {
return c.AuthClient.Patch(url, data, res)
} else {
return c.Http.Patch(url, data, res)
}
>>>>>>> 228056688660034ec5b8061e99c187aa0b1c85e7
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment