Documentation ¶
Overview ¶
Package contenttype validates the Content-Type header.
Index ¶
Constants ¶
View Source
const ( ContentTypeJSON = "application/json" ContentTypeFormEncoded = "application/x-www-form-urlencoded" ContentTypeFormData = "multipart/form-data" )
Some commonly used Content-Type values.
Variables ¶
View Source
var DefaultOptions = map[string]Options{ "": Options{ Methods: []string{http.MethodPost, http.MethodPut, http.MethodDelete}, ValidContentTypes: []string{ContentTypeJSON, ContentTypeFormEncoded, ContentTypeFormData}, AllowEmpty: false, }, }
DefaultOptions for the Valid() middleware if options if nil.
View Source
var JSON = map[string]Options{ "": Options{ Methods: []string{}, ValidContentTypes: []string{ContentTypeJSON}, AllowEmpty: false, }, }
JSON are options to allow only JSON for all requests verbs (GET included).
Functions ¶
Types ¶
type Options ¶
type Options struct { // Methods to validate; if the request method isn't in the list we won't do // anything. Methods []string // List of valid content-types. ValidContentTypes []string // AllowEmpty indicates if not sending a Content-Type header is allowed. AllowEmpty bool }
Options for Validate().
Click to show internal directories.
Click to hide internal directories.