Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use go's http.Headers, http.Request and url.Values types #3

Closed
dtjm opened this issue Apr 14, 2016 · 4 comments
Closed

Use go's http.Headers, http.Request and url.Values types #3

dtjm opened this issue Apr 14, 2016 · 4 comments
Labels
difficulty: medium fix is medium in difficulty status: work in progress Twilio or the community is in the process of implementing type: community enhancement feature request not on Twilio's roadmap

Comments

@dtjm
Copy link

dtjm commented Apr 14, 2016

Hi @thinkingserious, here are a few things I noticed:

  • Headers are modeled as map[string]string. Why not use the stdlib http.Headers for that instead?
  • The rest.Request type is similar to the stdlib http.Request type. Using the stdlib types could make the library more easy to integrate with other code. If you do that, then
  • Query params is modeled as map[string]string, usually in Go code this is done with the url.Values type

This code doesn't require a type assertion:

    var f interface{}
    err = json.Unmarshal(b, &f)
    if err != nil {
        fmt.Println(err)
    }
    m := f.(map[string]interface{})
    apiKey := m["api_key_id"].(string)

You can do this instead:

var f struct { 
  APIKeyID string `json:"api_key_id"`
}

err = json.Unmarshal(b, &f)

The only difference I see between the stdlib HTTP client and this one is that it returns a string for the response body instead of an io.Reader. Otherwise the overall level of complexity feels about the same as the stdlib client.

@dtjm dtjm added the type: question question directed at the library label Apr 14, 2016
@thinkingserious thinkingserious added type: community enhancement feature request not on Twilio's roadmap status: help wanted requesting help from the community and removed type: question question directed at the library labels May 23, 2016
@thinkingserious thinkingserious changed the title Feedback Use go's http.Headers, http.Request and url.Values types May 23, 2016
willmadison added a commit to willmadison/rest that referenced this issue Oct 9, 2016
…onse

primitives. Also updated example usage in the README.
@thinkingserious thinkingserious added the difficulty: medium fix is medium in difficulty label Oct 1, 2017
@vedhavyas
Copy link

@thinkingserious is this still up for grabs ?

@thinkingserious
Copy link
Contributor

Hi @vedhavyas,

I'm not sure if @willmadison is still working on this.

With Best Regards,

Elmer

@willmadison
Copy link

I've been done with this since last Octoberfest. I was blocked by some other merge holding this one up.

willmadison added a commit to willmadison/rest that referenced this issue Jan 8, 2018
willmadison added a commit to willmadison/rest that referenced this issue Jan 8, 2018
@thinkingserious thinkingserious added status: work in progress Twilio or the community is in the process of implementing and removed status: help wanted requesting help from the community labels Mar 6, 2018
@thinkingserious
Copy link
Contributor

Since there has been no activity on this issue since March 1, 2020, we are closing this issue. Please feel free to reopen or create a new issue if you still require assistance. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
difficulty: medium fix is medium in difficulty status: work in progress Twilio or the community is in the process of implementing type: community enhancement feature request not on Twilio's roadmap
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants