go-swagger: github.com/go-swagger/go-swagger/examples/stream-server/restapi/operations Index | Files

package operations

import "github.com/go-swagger/go-swagger/examples/stream-server/restapi/operations"

Index

Package Files

countdown_api.go elapse.go elapse_parameters.go elapse_responses.go elapse_urlbuilder.go

Constants

const ElapseForbiddenCode int = 403

ElapseForbiddenCode is the HTTP code returned for type ElapseForbidden

const ElapseOKCode int = 200

ElapseOKCode is the HTTP code returned for type ElapseOK

type CountdownAPI Uses

type CountdownAPI struct {
    Middleware func(middleware.Builder) http.Handler

    // BasicAuthenticator generates a runtime.Authenticator from the supplied basic auth function.
    // It has a default implementation in the security package, however you can replace it for your particular usage.
    BasicAuthenticator func(security.UserPassAuthentication) runtime.Authenticator
    // APIKeyAuthenticator generates a runtime.Authenticator from the supplied token auth function.
    // It has a default implementation in the security package, however you can replace it for your particular usage.
    APIKeyAuthenticator func(string, string, security.TokenAuthentication) runtime.Authenticator
    // BearerAuthenticator generates a runtime.Authenticator from the supplied bearer token auth function.
    // It has a default implementation in the security package, however you can replace it for your particular usage.
    BearerAuthenticator func(string, security.ScopedTokenAuthentication) runtime.Authenticator

    // JSONConsumer registers a consumer for a "application/json" mime type
    JSONConsumer runtime.Consumer

    // JSONProducer registers a producer for a "application/json" mime type
    JSONProducer runtime.Producer

    // ElapseHandler sets the operation handler for the elapse operation
    ElapseHandler ElapseHandler

    // ServeError is called when an error is received, there is a default handler
    // but you can set your own with this
    ServeError func(http.ResponseWriter, *http.Request, error)

    // ServerShutdown is called when the HTTP(S) server is shut down and done
    // handling all active connections and does not accept connections any more
    ServerShutdown func()

    // Custom command line argument groups with their descriptions
    CommandLineOptionsGroups []swag.CommandLineOptionsGroup

    // User defined logger function.
    Logger func(string, ...interface{})
    // contains filtered or unexported fields
}

CountdownAPI Example server for emitting newline delimited JSON

func NewCountdownAPI Uses

func NewCountdownAPI(spec *loads.Document) *CountdownAPI

NewCountdownAPI creates a new Countdown instance

func (*CountdownAPI) AuthenticatorsFor Uses

func (o *CountdownAPI) AuthenticatorsFor(schemes map[string]spec.SecurityScheme) map[string]runtime.Authenticator

AuthenticatorsFor gets the authenticators for the specified security schemes

func (*CountdownAPI) Authorizer Uses

func (o *CountdownAPI) Authorizer() runtime.Authorizer

Authorizer returns the registered authorizer

func (*CountdownAPI) ConsumersFor Uses

func (o *CountdownAPI) ConsumersFor(mediaTypes []string) map[string]runtime.Consumer

ConsumersFor gets the consumers for the specified media types

func (*CountdownAPI) Context Uses

func (o *CountdownAPI) Context() *middleware.Context

Context returns the middleware context for the countdown API

func (*CountdownAPI) DefaultConsumes Uses

func (o *CountdownAPI) DefaultConsumes() string

DefaultConsumes returns the default consumes media type

func (*CountdownAPI) DefaultProduces Uses

func (o *CountdownAPI) DefaultProduces() string

DefaultProduces returns the default produces media type

func (*CountdownAPI) Formats Uses

func (o *CountdownAPI) Formats() strfmt.Registry

Formats returns the registered string formats

func (*CountdownAPI) HandlerFor Uses

func (o *CountdownAPI) HandlerFor(method, path string) (http.Handler, bool)

HandlerFor gets a http.Handler for the provided operation method and path

func (*CountdownAPI) Init Uses

func (o *CountdownAPI) Init()

Init allows you to just initialize the handler cache, you can then recompose the middleware as you see fit

func (*CountdownAPI) ProducersFor Uses

func (o *CountdownAPI) ProducersFor(mediaTypes []string) map[string]runtime.Producer

ProducersFor gets the producers for the specified media types

func (*CountdownAPI) RegisterConsumer Uses

func (o *CountdownAPI) RegisterConsumer(mediaType string, consumer runtime.Consumer)

RegisterConsumer allows you to add (or override) a consumer for a media type.

func (*CountdownAPI) RegisterFormat Uses

func (o *CountdownAPI) RegisterFormat(name string, format strfmt.Format, validator strfmt.Validator)

RegisterFormat registers a custom format validator

func (*CountdownAPI) RegisterProducer Uses

func (o *CountdownAPI) RegisterProducer(mediaType string, producer runtime.Producer)

RegisterProducer allows you to add (or override) a producer for a media type.

func (*CountdownAPI) Serve Uses

func (o *CountdownAPI) Serve(builder middleware.Builder) http.Handler

Serve creates a http handler to serve the API over HTTP can be used directly in http.ListenAndServe(":8000", api.Serve(nil))

func (*CountdownAPI) ServeErrorFor Uses

func (o *CountdownAPI) ServeErrorFor(operationID string) func(http.ResponseWriter, *http.Request, error)

ServeErrorFor gets a error handler for a given operation id

func (*CountdownAPI) SetDefaultConsumes Uses

func (o *CountdownAPI) SetDefaultConsumes(mediaType string)

SetDefaultConsumes returns the default consumes media type

func (*CountdownAPI) SetDefaultProduces Uses

func (o *CountdownAPI) SetDefaultProduces(mediaType string)

SetDefaultProduces sets the default produces media type

func (*CountdownAPI) SetSpec Uses

func (o *CountdownAPI) SetSpec(spec *loads.Document)

SetSpec sets a spec that will be served for the clients.

func (*CountdownAPI) Validate Uses

func (o *CountdownAPI) Validate() error

Validate validates the registrations in the CountdownAPI

type Elapse Uses

type Elapse struct {
    Context *middleware.Context
    Handler ElapseHandler
}

Elapse swagger:route GET /elapse/{length} elapse

Count down the number of seconds

Count down the seconds remaining

func NewElapse Uses

func NewElapse(ctx *middleware.Context, handler ElapseHandler) *Elapse

NewElapse creates a new http.Handler for the elapse operation

func (*Elapse) ServeHTTP Uses

func (o *Elapse) ServeHTTP(rw http.ResponseWriter, r *http.Request)

type ElapseForbidden Uses

type ElapseForbidden struct {
}

ElapseForbidden Contrived - thrown when length of 11 is chosen

swagger:response elapseForbidden

func NewElapseForbidden Uses

func NewElapseForbidden() *ElapseForbidden

NewElapseForbidden creates ElapseForbidden with default headers values

func (*ElapseForbidden) WriteResponse Uses

func (o *ElapseForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer)

WriteResponse to the client

type ElapseHandler Uses

type ElapseHandler interface {
    Handle(ElapseParams) middleware.Responder
}

ElapseHandler interface for that can handle valid elapse params

type ElapseHandlerFunc Uses

type ElapseHandlerFunc func(ElapseParams) middleware.Responder

ElapseHandlerFunc turns a function with the right signature into a elapse handler

func (ElapseHandlerFunc) Handle Uses

func (fn ElapseHandlerFunc) Handle(params ElapseParams) middleware.Responder

Handle executing the request and returning a response

type ElapseOK Uses

type ElapseOK struct {

    /*
      In: Body
    */
    Payload io.ReadCloser `json:"body,omitempty"`
}

ElapseOK Secondly update on remaining time

swagger:response elapseOK

func NewElapseOK Uses

func NewElapseOK() *ElapseOK

NewElapseOK creates ElapseOK with default headers values

func (*ElapseOK) SetPayload Uses

func (o *ElapseOK) SetPayload(payload io.ReadCloser)

SetPayload sets the payload to the elapse o k response

func (*ElapseOK) WithPayload Uses

func (o *ElapseOK) WithPayload(payload io.ReadCloser) *ElapseOK

WithPayload adds the payload to the elapse o k response

func (*ElapseOK) WriteResponse Uses

func (o *ElapseOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer)

WriteResponse to the client

type ElapseParams Uses

type ElapseParams struct {

    // HTTP Request Object
    HTTPRequest *http.Request `json:"-"`

    /*How many seconds to count down
      Required: true
      Maximum: 30
      Minimum: 2
      In: path
    */
    Length int64
}

ElapseParams contains all the bound params for the elapse operation typically these are obtained from a http.Request

swagger:parameters elapse

func NewElapseParams Uses

func NewElapseParams() ElapseParams

NewElapseParams creates a new ElapseParams object no default values defined in spec.

func (*ElapseParams) BindRequest Uses

func (o *ElapseParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error

BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface for simple values it will use straight method calls.

To ensure default values, the struct must have been initialized with NewElapseParams() beforehand.

type ElapseURL Uses

type ElapseURL struct {
    Length int64
    // contains filtered or unexported fields
}

ElapseURL generates an URL for the elapse operation

func (*ElapseURL) Build Uses

func (o *ElapseURL) Build() (*url.URL, error)

Build a url path and query string

func (*ElapseURL) BuildFull Uses

func (o *ElapseURL) BuildFull(scheme, host string) (*url.URL, error)

BuildFull builds a full url with scheme, host, path and query string

func (*ElapseURL) Must Uses

func (o *ElapseURL) Must(u *url.URL, err error) *url.URL

Must is a helper function to panic when the url builder returns an error

func (*ElapseURL) SetBasePath Uses

func (o *ElapseURL) SetBasePath(bp string)

SetBasePath sets the base path for this url builder, only required when it's different from the base path specified in the swagger spec. When the value of the base path is an empty string

func (*ElapseURL) String Uses

func (o *ElapseURL) String() string

String returns the string representation of the path with query string

func (*ElapseURL) StringFull Uses

func (o *ElapseURL) StringFull(scheme, host string) string

StringFull returns the string representation of a complete url

func (*ElapseURL) WithBasePath Uses

func (o *ElapseURL) WithBasePath(bp string) *ElapseURL

WithBasePath sets the base path for this url builder, only required when it's different from the base path specified in the swagger spec. When the value of the base path is an empty string

Package operations imports 16 packages (graph) and is imported by 1 packages. Updated 2019-04-09. Refresh now. Tools for package owners.