rest

package
v0.0.0-...-db8c6ed Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 12, 2021 License: MIT Imports: 13 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsCallErrorStatusCode

func IsCallErrorStatusCode(httpStatusCode int) bool

func RespondError

func RespondError(w http.ResponseWriter, httpStatusCode int, errorData ErrorResponse)

func RespondErrorEmpty

func RespondErrorEmpty(w http.ResponseWriter, httpStatusCode int)

func SetUpCORSFilterByEnv

func SetUpCORSFilterByEnv(restContainer *restful.Container, envPrefix string) error

Types

type CORSFilterConfig

type CORSFilterConfig struct {
	AllowedHeaders *string `env:"ALLOWED_HEADERS"`
	AllowedMethods string  `env:"ALLOWED_METHODS"`
	AllowedDomains string  `env:"ALLOWED_DOMAINS"`
}

type ETagResponder

type ETagResponder struct {
	// contains filtered or unexported fields
}

func NewETagResponder

func NewETagResponder(bufferPoolSize int) *ETagResponder

func (*ETagResponder) RespondGetJSON

func (eTagResponder *ETagResponder) RespondGetJSON(
	req *restful.Request, resp *restful.Response, data interface{},
) error

func (*ETagResponder) RespondGetOctetStream

func (eTagResponder *ETagResponder) RespondGetOctetStream(
	req *restful.Request, resp *restful.Response, data []byte,
) error

func (*ETagResponder) RespondGetProtoMessage

func (eTagResponder *ETagResponder) RespondGetProtoMessage(
	req *restful.Request, resp *restful.Response, protoMsg proto.Message,
) error

type EmptyRequest

type EmptyRequest struct{}

type EmptyResponse

type EmptyResponse struct{}

type ErrorResponse

type ErrorResponse struct {
	Code string `json:"code,omitempty"`

	// We use the term description because it describes the error
	// to the developer rather than a message for the end user.
	Description string `json:"description,omitempty"`

	Fields []ErrorResponseField `json:"fields,omitempty"`
	DocURL string               `json:"doc_url,omitempty"`
}

type ErrorResponseField

type ErrorResponseField struct {
	Field       string `json:"field"`
	Code        string `json:"code,omitempty"`
	Description string `json:"description,omitempty"`
	DocURL      string `json:"doc_url,omitempty"`
}

type RequestContext

type RequestContext interface {
	api.CallContext
	HTTPRequest() *http.Request
}

type Responder

type Responder struct {
	// contains filtered or unexported fields
}

func RespondTo

func RespondTo(w http.ResponseWriter) Responder

func (Responder) EmptyError

func (r Responder) EmptyError(httpStatusCode int)

EmptyError responses with empty ErrorResponse with status code set to httpStatusCode.

func (Responder) Error

func (r Responder) Error(errorData ErrorResponse, httpStatusCode int)

Error responses with payload provided as errorResp

func (Responder) Success

func (r Responder) Success(successData interface{})

func (Responder) SuccessWithHTTPStatusCode

func (r Responder) SuccessWithHTTPStatusCode(successData interface{}, httpStatusCode int)

type StatsFilter

type StatsFilter struct {
	// contains filtered or unexported fields
}

func NewStatsFilter

func NewStatsFilter() *StatsFilter

func (*StatsFilter) Filter

func (sf *StatsFilter) Filter(req *restful.Request, resp *restful.Response, chain *restful.FilterChain)

func (*StatsFilter) StatsHandler

func (sf *StatsFilter) StatsHandler(w http.ResponseWriter, r *http.Request)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL