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

post form is complex to use #29

Open
elonzh opened this issue Jul 17, 2017 · 0 comments
Open

post form is complex to use #29

elonzh opened this issue Jul 17, 2017 · 0 comments

Comments

@elonzh
Copy link

elonzh commented Jul 17, 2017

u := "http://httpbin.org/post"
// Using net/http
v := make(url.Values) // url.Values has methods for value manipulating
v.Set("k1", "v1")
http.PostForm(u, v)
// or
http.PostForm(u, url.Values{"k1": []string{"v1"}})
// Using gentleman
r := gentleman.NewRequest()
// multipart.DataFields is actually same as url.Values, but without methods
d := make(multipart.DataFields)
d["k1"] = multipart.Values{"v1"} // multipart.Values is useless, why not just use []string?
r.Form(multipart.FormData{Data: d})
// or
r.Use(multipart.Fields(d))
r.Send()

Suggestions:

  1. remove multipart.Values, multipart.DataFields, using url.Values
  2. add a shortcut gentleman.Request.Fields
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant