...

Package runtime

import "github.com/go-openapi/runtime"
Overview
Index
Subdirectories

Overview ▾

Index ▾

Constants
Variables
func AllowsBody(r *http.Request) bool
func CanHaveBody(method string) bool
func ClosesStream(opts *byteStreamOpts)
func ContentType(headers http.Header) (string, string, error)
func HasBody(r *http.Request) bool
func IsSafe(r *http.Request) bool
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 APIError
    func NewAPIError(opName string, payload interface{}, code int) *APIError
    func (o *APIError) Error() string
    func (o *APIError) IsClientError() bool
    func (o *APIError) IsCode(code int) bool
    func (o *APIError) IsRedirect() bool
    func (o *APIError) IsServerError() bool
    func (o *APIError) IsSuccess() bool
    func (o *APIError) String() string
type Authenticator
type AuthenticatorFunc
    func (f AuthenticatorFunc) Authenticate(params interface{}) (bool, interface{}, error)
type Authorizer
type AuthorizerFunc
    func (f AuthorizerFunc) Authorize(r *http.Request, principal interface{}) error
type CSVOpt
    func WithCSVClosesStream() CSVOpt
    func WithCSVReaderOpts(reader csv.Reader) CSVOpt
    func WithCSVSkipLines(skipped int) CSVOpt
    func WithCSVWriterOpts(writer csv.Writer) CSVOpt
type CSVReader
type CSVWriter
type ClientAuthInfoWriter
type ClientAuthInfoWriterFunc
    func (fn ClientAuthInfoWriterFunc) AuthenticateRequest(req ClientRequest, reg strfmt.Registry) error
type ClientOperation
type ClientRequest
type ClientRequestWriter
type ClientRequestWriterFunc
    func (fn ClientRequestWriterFunc) WriteToRequest(req ClientRequest, reg strfmt.Registry) error
type ClientResponse
type ClientResponseReader
type ClientResponseReaderFunc
    func (read ClientResponseReaderFunc) ReadResponse(resp ClientResponse, consumer Consumer) (interface{}, error)
type ClientResponseStatus
type ClientTransport
type Consumer
    func ByteStreamConsumer(opts ...byteStreamOpt) Consumer
    func CSVConsumer(opts ...CSVOpt) Consumer
    func JSONConsumer() Consumer
    func TextConsumer() Consumer
    func XMLConsumer() Consumer
type ConsumerFunc
    func (fn ConsumerFunc) Consume(reader io.Reader, data interface{}) error
type ContextValidatable
type File
type Gettable
type NamedReadCloser
    func NamedReader(name string, rdr io.Reader) NamedReadCloser
type OperationHandler
type OperationHandlerFunc
    func (s OperationHandlerFunc) Handle(data interface{}) (interface{}, error)
type Producer
    func ByteStreamProducer(opts ...byteStreamOpt) Producer
    func CSVProducer(opts ...CSVOpt) Producer
    func JSONProducer() Producer
    func TextProducer() Producer
    func XMLProducer() Producer
type ProducerFunc
    func (f ProducerFunc) Produce(writer io.Writer, data interface{}) error
type TestClientRequest
    func (t *TestClientRequest) GetBody() []byte
    func (t *TestClientRequest) GetBodyParam() interface{}
    func (t *TestClientRequest) GetFileParam() map[string][]NamedReadCloser
    func (t *TestClientRequest) GetHeaderParams() http.Header
    func (t *TestClientRequest) GetMethod() string
    func (t *TestClientRequest) GetPath() string
    func (t *TestClientRequest) GetQueryParams() url.Values
    func (t *TestClientRequest) SetBodyParam(body interface{}) error
    func (t *TestClientRequest) SetFileParam(_ string, _ ...NamedReadCloser) error
    func (t *TestClientRequest) SetFormParam(_ string, _ ...string) error
    func (t *TestClientRequest) SetHeaderParam(name string, values ...string) error
    func (t *TestClientRequest) SetPathParam(_ string, _ string) error
    func (t *TestClientRequest) SetQueryParam(_ string, _ ...string) error
    func (t *TestClientRequest) SetTimeout(time.Duration) error
type Validatable
type Values
    func (v Values) GetOK(key string) (value []string, hasKey bool, hasValue bool)

Package files

bytestream.go client_auth_info.go client_operation.go client_request.go client_response.go constants.go csv.go csv_options.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"
    // HeaderAuthorization the Authorization header
    HeaderAuthorization = "Authorization"

    // 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"
    // CSVMime the csv mime type
    CSVMime = "text/csv"
    // MultipartFormMime the multipart form mime type
    MultipartFormMime = "multipart/form-data"
    // URLencodedFormMime the url encoded form mime type
    URLencodedFormMime = "application/x-www-form-urlencoded"
)

Variables

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

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

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

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

Statuses lists the most common HTTP status codes to default message taken from https://httpstatuses.com/

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",
}

func AllowsBody

func AllowsBody(r *http.Request) bool

AllowsBody returns true if the request allows for a body

func CanHaveBody

func CanHaveBody(method string) bool

CanHaveBody returns true if this method can have a body

func ClosesStream

func ClosesStream(opts *byteStreamOpts)

ClosesStream when the bytestream consumer or producer is finished

func ContentType

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

ContentType parses a content type header

func HasBody

func HasBody(r *http.Request) bool

HasBody returns true if this method needs a content-type

func IsSafe

func IsSafe(r *http.Request) bool

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

func JSONRequest

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

JSONRequest creates a new http request with json headers set.

It uses context.Background.

func ReadCollectionValue

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

ReadCollectionValue reads a collection value from a string data source

func ReadSingleValue

func ReadSingleValue(values Gettable, name string) string

ReadSingleValue reads a single value from the source

type APIError

APIError wraps an error model and captures the status code

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

func NewAPIError

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

NewAPIError creates a new API error

func (*APIError) Error

func (o *APIError) Error() string

func (*APIError) IsClientError

func (o *APIError) IsClientError() bool

IsClientError returns true when this elapse o k response returns a 4xx status code

func (*APIError) IsCode

func (o *APIError) IsCode(code int) bool

IsCode returns true when this elapse o k response returns a 4xx status code

func (*APIError) IsRedirect

func (o *APIError) IsRedirect() bool

IsRedirect returns true when this elapse o k response returns a 3xx status code

func (*APIError) IsServerError

func (o *APIError) IsServerError() bool

IsServerError returns true when this elapse o k response returns a 5xx status code

func (*APIError) IsSuccess

func (o *APIError) IsSuccess() bool

IsSuccess returns true when this elapse o k response returns a 2xx status code

func (*APIError) String

func (o *APIError) String() string

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 Authenticator interface {
    Authenticate(interface{}) (bool, interface{}, error)
}

type AuthenticatorFunc

AuthenticatorFunc turns a function into an authenticator

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

func (AuthenticatorFunc) Authenticate

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

Authenticate authenticates the request with the provided data

type Authorizer

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 Authorizer interface {
    Authorize(*http.Request, interface{}) error
}

type AuthorizerFunc

AuthorizerFunc turns a function into an authorizer

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

func (AuthorizerFunc) Authorize

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

Authorize authorizes the processing of the request for the principal

type CSVOpt

CSVOpts alter the behavior of the CSV consumer or producer.

type CSVOpt func(*csvOpts)

func WithCSVClosesStream

func WithCSVClosesStream() CSVOpt

func WithCSVReaderOpts

func WithCSVReaderOpts(reader csv.Reader) CSVOpt

WithCSVReaderOpts specifies the options to csv.Reader when reading CSV.

func WithCSVSkipLines

func WithCSVSkipLines(skipped int) CSVOpt

WithCSVSkipLines will skip header lines.

func WithCSVWriterOpts

func WithCSVWriterOpts(writer csv.Writer) CSVOpt

WithCSVWriterOpts specifies the options to csv.Writer when writing CSV.

type CSVReader

type CSVReader interface {
    Read() ([]string, error)
}

type CSVWriter

type CSVWriter interface {
    Write([]string) error
    Flush()
    Error() error
}

type ClientAuthInfoWriter

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

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

type ClientAuthInfoWriterFunc

A ClientAuthInfoWriterFunc converts a function to a request writer interface

type ClientAuthInfoWriterFunc func(ClientRequest, strfmt.Registry) error

func (ClientAuthInfoWriterFunc) AuthenticateRequest

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

AuthenticateRequest adds authentication data to the request

type ClientOperation

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

type ClientOperation struct {
    ID                 string
    Method             string
    PathPattern        string
    ProducesMediaTypes []string
    ConsumesMediaTypes []string
    Schemes            []string
    AuthInfo           ClientAuthInfoWriter
    Params             ClientRequestWriter
    Reader             ClientResponseReader
    Context            context.Context //nolint:containedctx // we precisely want this type to contain the request context
    Client             *http.Client
}

type ClientRequest

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

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

    GetHeaderParams() http.Header

    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
}

type ClientRequestWriter

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

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

type ClientRequestWriterFunc

ClientRequestWriterFunc converts a function to a request writer interface

type ClientRequestWriterFunc func(ClientRequest, strfmt.Registry) error

func (ClientRequestWriterFunc) WriteToRequest

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

WriteToRequest adds data to the request

type ClientResponse

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

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

type ClientResponseReader

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

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

type ClientResponseReaderFunc

A ClientResponseReaderFunc turns a function into a ClientResponseReader interface implementation

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

func (ClientResponseReaderFunc) ReadResponse

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

ReadResponse reads the response

type ClientResponseStatus

A ClientResponseStatus is a common interface implemented by all responses on the generated code You can use this to treat any client response based on status code

type ClientResponseStatus interface {
    IsSuccess() bool
    IsRedirect() bool
    IsClientError() bool
    IsServerError() bool
    IsCode(int) bool
}

type ClientTransport

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

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

type Consumer

Consumer implementations know how to bind the values on the provided interface to data provided by the request body

type Consumer interface {
    // Consume performs the binding of request values
    Consume(io.Reader, interface{}) error
}

func ByteStreamConsumer

func ByteStreamConsumer(opts ...byteStreamOpt) Consumer

ByteStreamConsumer creates a consumer for byte streams.

The consumer consumes from a provided reader into the data passed by reference.

Supported output underlying types and interfaces, prioritized in this order: - io.ReaderFrom (for maximum control) - io.Writer (performs io.Copy) - encoding.BinaryUnmarshaler - *string - *[]byte

func CSVConsumer

func CSVConsumer(opts ...CSVOpt) Consumer

CSVConsumer creates a new CSV consumer.

The consumer consumes CSV records from a provided reader into the data passed by reference.

CSVOpts options may be specified to alter the default CSV behavior on the reader and the writer side (e.g. separator, skip header, ...). The defaults are those of the standard library's csv.Reader and csv.Writer.

Supported output underlying types and interfaces, prioritized in this order: - *csv.Writer - CSVWriter (writer options are ignored) - io.Writer (as raw bytes) - io.ReaderFrom (as raw bytes) - encoding.BinaryUnmarshaler (as raw bytes) - *[][]string (as a collection of records) - *[]byte (as raw bytes) - *string (a raw bytes)

The consumer prioritizes situations where buffering the input is not required.

func JSONConsumer

func JSONConsumer() Consumer

JSONConsumer creates a new JSON consumer

func TextConsumer

func TextConsumer() Consumer

TextConsumer creates a new text consumer

func XMLConsumer

func XMLConsumer() Consumer

XMLConsumer creates a new XML consumer

type ConsumerFunc

ConsumerFunc represents a function that can be used as a consumer

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

func (ConsumerFunc) Consume

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

Consume consumes the reader into the data parameter

type ContextValidatable

ContextValidatable 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 context validations obtained from the spec

type ContextValidatable interface {
    ContextValidate(context.Context, strfmt.Registry) error
}

type File

type File = swag.File

type Gettable

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

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

type NamedReadCloser

NamedReadCloser represents a named ReadCloser interface

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

func NamedReader

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

NamedReader creates a NamedReadCloser for use as file upload

type OperationHandler

OperationHandler a handler for a swagger operation

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

type OperationHandlerFunc

OperationHandlerFunc an adapter for a function to the OperationHandler interface

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

func (OperationHandlerFunc) Handle

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

Handle implements the operation handler interface

type Producer

Producer implementations know how to turn the provided interface into a valid HTTP response

type Producer interface {
    // Produce writes to the http response
    Produce(io.Writer, interface{}) error
}

func ByteStreamProducer

func ByteStreamProducer(opts ...byteStreamOpt) Producer

ByteStreamProducer creates a producer for byte streams.

The producer takes input data then writes to an output writer (essentially as a pipe).

Supported input underlying types and interfaces, prioritized in this order: - io.WriterTo (for maximum control) - io.Reader (performs io.Copy). A ReadCloser is closed before exiting. - encoding.BinaryMarshaler - error (writes as a string) - []byte - string - struct, other slices: writes as JSON

func CSVProducer

func CSVProducer(opts ...CSVOpt) Producer

CSVProducer creates a new CSV producer.

The producer takes input data then writes as CSV to an output writer (essentially as a pipe).

Supported input underlying types and interfaces, prioritized in this order: - *csv.Reader - CSVReader (reader options are ignored) - io.Reader - io.WriterTo - encoding.BinaryMarshaler - [][]string - []byte - string

The producer prioritizes situations where buffering the input is not required.

func JSONProducer

func JSONProducer() Producer

JSONProducer creates a new JSON producer

func TextProducer

func TextProducer() Producer

TextProducer creates a new text producer

func XMLProducer

func XMLProducer() Producer

XMLProducer creates a new XML producer

type ProducerFunc

ProducerFunc represents a function that can be used as a producer

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

func (ProducerFunc) Produce

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

Produce produces the response for the provided data

type TestClientRequest

type TestClientRequest struct {
    Headers http.Header
    Body    interface{}
}

func (*TestClientRequest) GetBody

func (t *TestClientRequest) GetBody() []byte

func (*TestClientRequest) GetBodyParam

func (t *TestClientRequest) GetBodyParam() interface{}

func (*TestClientRequest) GetFileParam

func (t *TestClientRequest) GetFileParam() map[string][]NamedReadCloser

func (*TestClientRequest) GetHeaderParams

func (t *TestClientRequest) GetHeaderParams() http.Header

func (*TestClientRequest) GetMethod

func (t *TestClientRequest) GetMethod() string

func (*TestClientRequest) GetPath

func (t *TestClientRequest) GetPath() string

func (*TestClientRequest) GetQueryParams

func (t *TestClientRequest) GetQueryParams() url.Values

func (*TestClientRequest) SetBodyParam

func (t *TestClientRequest) SetBodyParam(body interface{}) error

func (*TestClientRequest) SetFileParam

func (t *TestClientRequest) SetFileParam(_ string, _ ...NamedReadCloser) error

func (*TestClientRequest) SetFormParam

func (t *TestClientRequest) SetFormParam(_ string, _ ...string) error

func (*TestClientRequest) SetHeaderParam

func (t *TestClientRequest) SetHeaderParam(name string, values ...string) error

func (*TestClientRequest) SetPathParam

func (t *TestClientRequest) SetPathParam(_ string, _ string) error

func (*TestClientRequest) SetQueryParam

func (t *TestClientRequest) SetQueryParam(_ string, _ ...string) error

func (*TestClientRequest) SetTimeout

func (t *TestClientRequest) SetTimeout(time.Duration) error

type Validatable

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 Validatable interface {
    Validate(strfmt.Registry) error
}

type Values

Values typically represent parameters on a http request.

type Values map[string][]string

func (Values) GetOK

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.

Subdirectories

Name Synopsis
..
client
flagext
logger
middleware Package middleware provides the library with helper functions for serving swagger APIs.
denco Package denco provides fast URL router.
header Package header provides functions for parsing HTTP headers.
untyped
security
yamlpc