README
¶
gentleman/multipart

gentleman's plugin to easily define multipart/form-data
bodies supporting files and string based fields.
Installation
go get -u gopkg.in/h2non/gentleman.v0/plugins/multipart
API
See godoc reference.
Example
package main
import (
"fmt"
"gopkg.in/h2non/gentleman.v0"
"gopkg.in/h2non/gentleman.v0/plugins/multipart"
)
func main() {
// Create a new client
cli := gentleman.New()
// Create a text based form fields
fields := map[string]string{"foo": "bar", "bar": "baz"}
cli.Use(multipart.Fields(fields))
// Perform the request
res, err := cli.Request().Method("POST").URL("http://httpbin.org/post").Send()
if err != nil {
fmt.Printf("Request error: %s\n", err)
return
}
if !res.Ok {
fmt.Printf("Invalid server response: %d\n", res.StatusCode)
return
}
fmt.Printf("Status: %d\n", res.StatusCode)
fmt.Printf("Body: %s", res.String())
}
License
MIT - Tomas Aparicio
Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Data ¶
Data creates custom form based on the given form data who can have files and string based fields.
func Fields ¶
func Fields(fields DataFields) p.Plugin
Fields creates a new multipart form based on string based fields.
Types ¶
type DataFields ¶
DataFields represents a map of text based fields.
type FormData ¶
type FormData struct { Data DataFields Files []FormFile }
FormData represents the supported form fields by file and string data.
Click to show internal directories.
Click to hide internal directories.