import "github.com/nexneo/easyreq"
Package easyreq provides support for creating requests easily for multipart form request or json API requests.
Usage import "github.com/nexneo/easyreq"
Form Example
f := easyreq.Form{}
f.Field().Add("Name", "John")
f.File().Add("File", "test-files/logo.png")
f.Header().Add("Host", "example.com")
req, err := f.Request("POST", "http://example.com/postform")
or
easyreq.NewForm(fields, nil).Do("GET", "http://example.com/")
easyreq.NewForm(fields, files).Do("POST", "http://example.com/")
Form will choose Content-Type based on any file added or not.
Json Example
j := easyreq.Json{}
j.Header().Add("Host", "example.com")
req, err := j.Set(v).Request("POST", "http://example.com/postjson")
or
req, err := easyreq.NewJson(v).Request("PUT", "http://example.com/putjson")
type Form struct {
// contains filtered or unexported fields
}Structure that contains form fields and upload files, can optionally have request headers.
Creates new Form with given fields and files
Helper funcation send requests using http.DefaultClient
Returns url.Values which should be used to Add form field
Returns url.Values which should be used to Add form file
Returns request based on current Fields and Files assoicated with form Request will always have correct Content-Type set for POST and PUT
Helper to set Basic Auth header for request
type Json struct {
// contains filtered or unexported fields
}Helper funcation send requests using http.DefaultClient
Returns request based on current payload assoicated with Json request, it will always have correct Content-Type set
Inteface implemeted by Form, Json structures
Package easyreq imports 11 packages (graph) and is imported by 1 packages. Updated 2016-07-15. Refresh now. Tools for package owners.