Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrMissingFile = errors.New("httputil: no such file")
Functions ¶
func GetFormFile ¶
func GetFormFile(r *http.Request, key string) (fileContent []byte, fileHeader *multipart.FileHeader, err error)
GetFormFile returns the first file content and header for the provided form key. GetFormfile uses FormFile function underneth so calls ParseMultipartForm and ParseForm if necessary
Types ¶
type MediaType ¶
MediaType represents a media type from an Accept header. Name property is the MIME type name (like "application/json"). Params property contains the media type option parameters.
func ParseMediaTypes ¶
ParseMediaTypes will parse one or multiple media type directives (i.e Accept or Content-Type headers) and return an array of MediaType representing the MIME type name and optional parameters.
Example ¶
package main import ( "fmt" "github.com/ehsoc/rest/httputil" ) func main() { accept := "application/json; indent=4, application/xml" result := httputil.ParseMediaTypes(accept) for _, mt := range result { fmt.Println(mt.Name, mt.Params) } }
Output: application/json map[indent:4] application/xml map[]
Click to show internal directories.
Click to hide internal directories.