h2non/gentleman

post form is complex to use

elonzh opened this issue · 0 comments

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