runtime: github.com/go-openapi/runtime Index | Files | Directories

package runtime

import "github.com/go-openapi/runtime"

Index

Package Files

bytestream.go client_auth_info.go client_operation.go client_request.go client_response.go constants.go discard.go file.go headers.go interfaces.go json.go request.go statuses.go text.go values.go xml.go

Constants

const (
    // HeaderContentType represents a http content-type header, it's value is supposed to be a mime type
    HeaderContentType = "Content-Type"

    // HeaderTransferEncoding represents a http transfer-encoding header.
    HeaderTransferEncoding = "Transfer-Encoding"

    // 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"
    // XMLMime the xml mime type
    XMLMime = "application/xml"
    // TextMime the text mime type
    TextMime = "text/plain"
    // HTMLMime the html mime type
    HTMLMime = "text/html"
    // MultipartFormMime the multipart form mime type
    MultipartFormMime = "multipart/form-data"
    // URLencodedFormMime the url encoded form mime type
    URLencodedFormMime = "application/x-www-form-urlencoded"
)

Variables

var DiscardConsumer = ConsumerFunc(func(_ io.Reader, _ interface{}) error { return nil })

DiscardConsumer does absolutely nothing, it's a black hole.

var DiscardProducer = ProducerFunc(func(_ io.Writer, _ interface{}) error { return nil })

DiscardProducer does absolutely nothing, it's a black hole.

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: "Multi-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 https://httpstatuses.com/

func AllowsBody Uses

func AllowsBody(r *http.Request) bool

AllowsBody returns true if the request allows for a body

func CanHaveBody Uses

func CanHaveBody(method string) bool

CanHaveBody returns true if this method can have a body

func ClosesStream Uses

func ClosesStream(opts *byteStreamOpts)

ClosesStream when the bytestream consumer or producer is finished

func ContentType Uses

func ContentType(headers http.Header) (string, string, error)

ContentType parses a content type header

func HasBody Uses

func HasBody(r *http.Request) bool

HasBody returns true if this method needs a content-type

func IsSafe Uses

func IsSafe(r *http.Request) bool

IsSafe returns true if this is a request with a safe method

func JSONRequest Uses

func JSONRequest(method, urlStr string, body io.Reader) (*http.Request, error)

JSONRequest creates a new http request with json headers set

func ReadCollectionValue Uses

func ReadCollectionValue(values Gettable, name, collectionFormat string) []string

ReadCollectionValue reads a collection value from a string data source

func ReadSingleValue Uses

func ReadSingleValue(values Gettable, name string) string

ReadSingleValue reads a single value from the source

type APIError Uses

type APIError struct {
    OperationName string
    Response      interface{}
    Code          int
}

APIError wraps an error model and captures the status code

func NewAPIError Uses

func NewAPIError(opName string, payload interface{}, code int) *APIError

NewAPIError creates a new API error

func (*APIError) Error Uses

func (a *APIError) Error() string

type Authenticator Uses

type Authenticator interface {
    Authenticate(interface{}) (bool, interface{}, error)
}

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 Uses

type AuthenticatorFunc func(interface{}) (bool, interface{}, error)

AuthenticatorFunc turns a function into an authenticator

func (AuthenticatorFunc) Authenticate Uses

func (f AuthenticatorFunc) Authenticate(params interface{}) (bool, interface{}, error)

Authenticate authenticates the request with the provided data

type Authorizer Uses

type Authorizer interface {
    Authorize(*http.Request, interface{}) error
}

Authorizer represents an authorization strategy implementations of Authorizer know how to authorize the principal object using the request data and returns error if unauthorized

type AuthorizerFunc Uses

type AuthorizerFunc func(*http.Request, interface{}) error

AuthorizerFunc turns a function into an authorizer

func (AuthorizerFunc) Authorize Uses

func (f AuthorizerFunc) Authorize(r *http.Request, principal interface{}) error

Authorize authorizes the processing of the request for the principal

type ClientAuthInfoWriter Uses

type ClientAuthInfoWriter interface {
    AuthenticateRequest(ClientRequest, strfmt.Registry) error
}

A ClientAuthInfoWriter implementor knows how to write authentication info to a request

type ClientAuthInfoWriterFunc Uses

type ClientAuthInfoWriterFunc func(ClientRequest, strfmt.Registry) error

A ClientAuthInfoWriterFunc converts a function to a request writer interface

func (ClientAuthInfoWriterFunc) AuthenticateRequest Uses

func (fn ClientAuthInfoWriterFunc) AuthenticateRequest(req ClientRequest, reg strfmt.Registry) error

AuthenticateRequest adds authentication data to the request

type ClientOperation Uses

type ClientOperation struct {
    ID                 string
    Method             string
    PathPattern        string
    ProducesMediaTypes []string
    ConsumesMediaTypes []string
    Schemes            []string
    AuthInfo           ClientAuthInfoWriter
    Params             ClientRequestWriter
    Reader             ClientResponseReader
    Context            context.Context
    Client             *http.Client
}

ClientOperation represents the context for a swagger operation to be submitted to the transport

type ClientRequest Uses

type ClientRequest interface {
    SetHeaderParam(string, ...string) error

    SetQueryParam(string, ...string) error

    SetFormParam(string, ...string) error

    SetPathParam(string, string) error

    GetQueryParams() url.Values

    SetFileParam(string, ...NamedReadCloser) error

    SetBodyParam(interface{}) error

    SetTimeout(time.Duration) error

    GetMethod() string

    GetPath() string

    GetBody() []byte

    GetBodyParam() interface{}

    GetFileParam() map[string][]NamedReadCloser
}

ClientRequest is an interface for things that know how to add information to a swagger client request

type ClientRequestWriter Uses

type ClientRequestWriter interface {
    WriteToRequest(ClientRequest, strfmt.Registry) error
}

ClientRequestWriter is an interface for things that know how to write to a request

type ClientRequestWriterFunc Uses

type ClientRequestWriterFunc func(ClientRequest, strfmt.Registry) error

ClientRequestWriterFunc converts a function to a request writer interface

func (ClientRequestWriterFunc) WriteToRequest Uses

func (fn ClientRequestWriterFunc) WriteToRequest(req ClientRequest, reg strfmt.Registry) error

WriteToRequest adds data to the request

type ClientResponse Uses

type ClientResponse interface {
    Code() int
    Message() string
    GetHeader(string) string
    Body() io.ReadCloser
}

A ClientResponse represents a client response This bridges between responses obtained from different transports

type ClientResponseReader Uses

type ClientResponseReader interface {
    ReadResponse(ClientResponse, Consumer) (interface{}, error)
}

A ClientResponseReader is an interface for things want to read a response. An application of this is to create structs from response values

type ClientResponseReaderFunc Uses

type ClientResponseReaderFunc func(ClientResponse, Consumer) (interface{}, error)

A ClientResponseReaderFunc turns a function into a ClientResponseReader interface implementation

func (ClientResponseReaderFunc) ReadResponse Uses

func (read ClientResponseReaderFunc) ReadResponse(resp ClientResponse, consumer Consumer) (interface{}, error)

ReadResponse reads the response

type ClientTransport Uses

type ClientTransport interface {
    //Submit(string, RequestWriter, ResponseReader, AuthInfoWriter) (interface{}, error)
    Submit(*ClientOperation) (interface{}, error)
}

A ClientTransport implementor knows how to submit Request objects to some destination

type Consumer Uses

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

func ByteStreamConsumer Uses

func ByteStreamConsumer(opts ...byteStreamOpt) Consumer

ByteStreamConsumer creates a consmer for byte streams, takes a Writer/BinaryUnmarshaler interface or binary slice by reference, and reads from the provided reader

func JSONConsumer Uses

func JSONConsumer() Consumer

JSONConsumer creates a new JSON consumer

func TextConsumer Uses

func TextConsumer() Consumer

TextConsumer creates a new text consumer

func XMLConsumer Uses

func XMLConsumer() Consumer

XMLConsumer creates a new XML consumer

type ConsumerFunc Uses

type ConsumerFunc func(io.Reader, interface{}) error

ConsumerFunc represents a function that can be used as a consumer

func (ConsumerFunc) Consume Uses

func (fn ConsumerFunc) Consume(reader io.Reader, data interface{}) error

Consume consumes the reader into the data parameter

type File Uses

type File struct {
    Data   multipart.File
    Header *multipart.FileHeader
}

File represents an uploaded file.

func (*File) Close Uses

func (f *File) Close() error

Close the file

func (*File) Read Uses

func (f *File) Read(p []byte) (n int, err error)

Read bytes from the file

type Gettable Uses

type Gettable interface {
    GetOK(string) ([]string, bool, bool)
}

Gettable for things with a method GetOK(string) (data string, hasKey bool, hasValue bool)

type NamedReadCloser Uses

type NamedReadCloser interface {
    io.ReadCloser
    Name() string
}

NamedReadCloser represents a named ReadCloser interface

func NamedReader Uses

func NamedReader(name string, rdr io.Reader) NamedReadCloser

NamedReader creates a NamedReadCloser for use as file upload

type OperationHandler Uses

type OperationHandler interface {
    Handle(interface{}) (interface{}, error)
}

OperationHandler a handler for a swagger operation

type OperationHandlerFunc Uses

type OperationHandlerFunc func(interface{}) (interface{}, error)

OperationHandlerFunc an adapter for a function to the OperationHandler interface

func (OperationHandlerFunc) Handle Uses

func (s OperationHandlerFunc) Handle(data interface{}) (interface{}, error)

Handle implements the operation handler interface

type Producer Uses

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

func ByteStreamProducer Uses

func ByteStreamProducer(opts ...byteStreamOpt) Producer

ByteStreamProducer creates a producer for byte streams, takes a Reader/BinaryMarshaler interface or binary slice, and writes to a writer (essentially a pipe)

func JSONProducer Uses

func JSONProducer() Producer

JSONProducer creates a new JSON producer

func TextProducer Uses

func TextProducer() Producer

TextProducer creates a new text producer

func XMLProducer Uses

func XMLProducer() Producer

XMLProducer creates a new XML producer

type ProducerFunc Uses

type ProducerFunc func(io.Writer, interface{}) error

ProducerFunc represents a function that can be used as a producer

func (ProducerFunc) Produce Uses

func (f ProducerFunc) Produce(writer io.Writer, data interface{}) error

Produce produces the response for the provided data

type Validatable Uses

type Validatable interface {
    Validate(strfmt.Registry) error
}

Validatable types implementing this interface allow customizing their validation this will be used instead of the reflective validation 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

type Values Uses

type Values map[string][]string

Values typically represent parameters on a http request.

func (Values) GetOK Uses

func (v Values) GetOK(key string) (value []string, hasKey bool, hasValue bool)

GetOK returns the values collection for the given key. When the key is present in the map it will return true for hasKey. When the value is not empty it will return true for hasValue.

Directories

PathSynopsis
client
flagext
internal/testing
internal/testing/petstore
internal/testing/simplepetstore
logger
middlewarePackage middleware provides the library with helper functions for serving swagger APIs.
middleware/dencoPackage denco provides fast URL router.
middleware/headerPackage header provides functions for parsing HTTP headers.
middleware/untyped
security
yamlpc

Package runtime imports 19 packages (graph) and is imported by 994 packages. Updated 2019-01-15. Refresh now. Tools for package owners.