Merge pull request #12 from 178inaba/url_to_u

Fix var name url to u
pull/13/head
mattn 2017-04-15 12:19:38 +09:00 committed by GitHub
commit 4f3888ff3c
3 changed files with 12 additions and 12 deletions

View File

@ -45,13 +45,13 @@ func RegisterApp(appConfig *AppConfig) (*Application, error) {
params.Set("scopes", appConfig.Scopes) params.Set("scopes", appConfig.Scopes)
params.Set("website", appConfig.Website) params.Set("website", appConfig.Website)
url, err := url.Parse(appConfig.Server) u, err := url.Parse(appConfig.Server)
if err != nil { if err != nil {
return nil, err return nil, err
} }
url.Path = path.Join(url.Path, "/api/v1/apps") u.Path = path.Join(u.Path, "/api/v1/apps")
req, err := http.NewRequest(http.MethodPost, url.String(), strings.NewReader(params.Encode())) req, err := http.NewRequest(http.MethodPost, u.String(), strings.NewReader(params.Encode()))
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@ -24,14 +24,14 @@ type Client struct {
} }
func (c *Client) doAPI(method string, uri string, params url.Values, res interface{}) error { func (c *Client) doAPI(method string, uri string, params url.Values, res interface{}) error {
url, err := url.Parse(c.config.Server) u, err := url.Parse(c.config.Server)
if err != nil { if err != nil {
return err return err
} }
url.Path = path.Join(url.Path, uri) u.Path = path.Join(u.Path, uri)
var resp *http.Response var resp *http.Response
req, err := http.NewRequest(method, url.String(), strings.NewReader(params.Encode())) req, err := http.NewRequest(method, u.String(), strings.NewReader(params.Encode()))
if err != nil { if err != nil {
return err return err
} }
@ -70,13 +70,13 @@ func (c *Client) Authenticate(username, password string) error {
params.Set("password", password) params.Set("password", password)
params.Set("scope", "read write follow") params.Set("scope", "read write follow")
url, err := url.Parse(c.config.Server) u, err := url.Parse(c.config.Server)
if err != nil { if err != nil {
return err return err
} }
url.Path = path.Join(url.Path, "/oauth/token") u.Path = path.Join(u.Path, "/oauth/token")
req, err := http.NewRequest(http.MethodPost, url.String(), strings.NewReader(params.Encode())) req, err := http.NewRequest(http.MethodPost, u.String(), strings.NewReader(params.Encode()))
if err != nil { if err != nil {
return err return err
} }

View File

@ -69,11 +69,11 @@ func handleReader(ctx context.Context, q chan Event, r io.Reader) error {
// StreamingPublic return channel to read events. // StreamingPublic return channel to read events.
func (c *Client) StreamingPublic(ctx context.Context) (chan Event, error) { func (c *Client) StreamingPublic(ctx context.Context) (chan Event, error) {
url, err := url.Parse(c.config.Server) u, err := url.Parse(c.config.Server)
if err != nil { if err != nil {
return nil, err return nil, err
} }
url.Path = path.Join(url.Path, "/api/v1/streaming/public") u.Path = path.Join(u.Path, "/api/v1/streaming/public")
var resp *http.Response var resp *http.Response
@ -82,7 +82,7 @@ func (c *Client) StreamingPublic(ctx context.Context) (chan Event, error) {
defer ctx.Done() defer ctx.Done()
for { for {
req, err := http.NewRequest(http.MethodGet, url.String(), nil) req, err := http.NewRequest(http.MethodGet, u.String(), nil)
if err == nil { if err == nil {
req.Header.Set("Authorization", "Bearer "+c.config.AccessToken) req.Header.Set("Authorization", "Bearer "+c.config.AccessToken)
resp, err = c.Do(req) resp, err = c.Do(req)