Documentation ¶
Index ¶
- Constants
- Variables
- func CanHaveBody(method string) bool
- func ContentType(headers http.Header) (string, string, *errors.ParseError)
- func JSONRequest(method, urlStr string, body io.Reader) (*http.Request, error)
- func ReadCollectionValue(values Gettable, name, collectionFormat string) []string
- func ReadSingleValue(values Gettable, name string) string
- type Authenticator
- type AuthenticatorFunc
- type Consumer
- type ConsumerFunc
- type File
- type Gettable
- type OperationHandler
- type OperationHandlerFunc
- type Producer
- type ProducerFunc
- type Validatable
Constants ¶
const ( // HeaderContentType represents a http content-type header, it's value is supposed to be a mime type HeaderContentType = "Content-Type" // HeaderAccept the Accept header HeaderAccept = "Accept" // DefaultMime the default fallback mime type DefaultMime = "application/octet-stream" // JSONMime the json mime type JSONMime = "application/json" // YAMLMime the yaml mime type YAMLMime = "application/x-yaml" // MultipartFormMime the multipart form mime type MultipartFormMime = "multipart/form-data" )
Variables ¶
var Statuses = map[int]string{
100: "Continue",
101: "Switching Protocols",
102: "Processing",
103: "Checkpoint",
122: "URI too long",
200: "OK",
201: "Created",
202: "Accepted",
203: "Request Processed",
204: "No Content",
205: "Reset Content",
206: "Partial Content",
207: "Mutli-Status",
208: "Already Reported",
226: "IM Used",
300: "Multiple Choices",
301: "Moved Permanently",
302: "Found",
303: "See Other",
304: "Not Modified",
305: "Use Proxy",
306: "Switch Proxy",
307: "Temporary Redirect",
308: "Permanent Redirect",
400: "Bad Request",
401: "Unauthorized",
402: "Payment Required",
403: "Forbidden",
404: "Not Found",
405: "Method Not Allowed",
406: "Not Acceptable",
407: "Proxy Authentication Required",
408: "Request Timeout",
409: "Conflict",
410: "Gone",
411: "Length Required",
412: "Precondition Failed",
413: "Request Entity Too Large",
414: "Request-URI Too Long",
415: "Unsupported Media Type",
416: "Request Range Not Satisfiable",
417: "Expectation Failed",
418: "I'm a teapot",
420: "Enhance Your Calm",
422: "Unprocessable Entity",
423: "Locked",
424: "Failed Dependency",
426: "Upgrade Required",
428: "Precondition Required",
429: "Too Many Requests",
431: "Request Header Fields Too Large",
444: "No Response",
449: "Retry With",
450: "Blocked by Windows Parental Controls",
451: "Wrong Exchange Server",
499: "Client Closed Request",
500: "Internal Server Error",
501: "Not Implemented",
502: "Bad Gateway",
503: "Service Unavailable",
504: "Gateway Timeout",
505: "HTTP Version Not Supported",
506: "Variant Also Negotiates",
507: "Insufficient Storage",
508: "Loop Detected",
509: "Bandwidth Limit Exceeded",
510: "Not Extended",
511: "Network Authentication Required",
598: "Network read timeout error",
599: "Network connect timeout error",
}
Statuses lists the most common HTTP status codes to default message taken from http://status.es
Functions ¶
func CanHaveBody ¶
CanHaveBody returns true if this method can have a body
func ContentType ¶
ContentType parses a content type header
func JSONRequest ¶
JSONRequest creates a new http request with json headers set
func ReadCollectionValue ¶
ReadCollectionValue reads a collection value from a string data source
func ReadSingleValue ¶
ReadSingleValue reads a single value from the source
Types ¶
type Authenticator ¶
Authenticator represents an authentication strategy implementations of Authenticator know how to authenticate the request data and translate that into a valid principal object or an error
type AuthenticatorFunc ¶
AuthenticatorFunc turns a function into an authenticator
func (AuthenticatorFunc) Authenticate ¶
func (f AuthenticatorFunc) Authenticate(params interface{}) (bool, interface{}, error)
Authenticate authenticates the request with the provided data
type Consumer ¶
type Consumer interface { // Consume performs the binding of request values Consume(io.Reader, interface{}) error }
Consumer implementations know how to bind the values on the provided interface to data provided by the request body
type ConsumerFunc ¶
ConsumerFunc represents a function that can be used as a consumer
type File ¶
type File struct { Data multipart.File Header *multipart.FileHeader }
File represents an uploaded file.
type OperationHandler ¶
type OperationHandler interface {
Handle(interface{}) (interface{}, error)
}
OperationHandler a handler for a swagger operation
type OperationHandlerFunc ¶
type OperationHandlerFunc func(interface{}) (interface{}, error)
OperationHandlerFunc an adapter for a function to the OperationHandler interface
func (OperationHandlerFunc) Handle ¶
func (s OperationHandlerFunc) Handle(data interface{}) (interface{}, error)
Handle implements the operation handler interface
type Producer ¶
type Producer interface { // Produce writes to the http response Produce(io.Writer, interface{}) error }
Producer implementations know how to turn the provided interface into a valid HTTP response
type ProducerFunc ¶
ProducerFunc represents a function that can be used as a producer
type Validatable ¶
Validatable types implementing this interface allow customizing their validation this will be used instead of the reflective valditation based on the spec document. the implementations are assumed to have been generated by the swagger tool so they should contain all the validations obtained from the spec
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package client contains a client to send http requests to a swagger API.
|
Package client contains a client to send http requests to a swagger API. |
Package middleware provides the library with helper functions for serving swagger APIs.
|
Package middleware provides the library with helper functions for serving swagger APIs. |