Use go's http.Headers, http.Request and url.Values types
dtjm opened this issue · 4 comments
dtjm commented
Hi @thinkingserious, here are a few things I noticed:
- Headers are modeled as
map[string]string
. Why not use the stdlibhttp.Headers
for that instead? - The
rest.Request
type is similar to the stdlibhttp.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 theurl.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.
vedhavyas commented
@thinkingserious is this still up for grabs ?
thinkingserious commented
willmadison commented
I've been done with this since last Octoberfest. I was blocked by some other merge holding this one up.
thinkingserious commented
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!