respond

package
v0.0.0-...-0288797 Latest Latest
Warning

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

Go to latest
Published: May 11, 2017 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HTMLMIME = "text/html; charset=utf-8"
	JSONMIME = "application/json; charset=utf-8"
	TextMIME = "text/plain; charset=utf-8"

	ContentType   = "Content-Type"
	AccessControl = "Access-Control-Allow-"
)

Common MIME types.

View Source
const (
	StatusUnknown            = http.StatusInternalServerError
	StatusCanceled           = http.StatusRequestTimeout
	StatusDeadlineExceeded   = http.StatusRequestTimeout
	StatusAlreadyExists      = http.StatusConflict
	StatusFailedPrecondition = http.StatusPreconditionFailed
	StatusAborted            = http.StatusConflict
	StatusDataLoss           = http.StatusInternalServerError
)

Variables

This section is empty.

Functions

func Aborted

func Aborted(w http.ResponseWriter, err error)

Aborted sends an error response with StatusAborted.

func AlreadyExists

func AlreadyExists(w http.ResponseWriter, err error)

AlreadyExists sends an error response with StatusAlreadyExists.

func Any

func Any(w http.ResponseWriter, err error)

Any determines the type of response to write to the http.ResponseWriter from the error's RPC code. err must != nil. Unknown errors are considered to be Internal Server Errors.

func BadMethod

func BadMethod(w http.ResponseWriter, _ error)

BadMethod reponds with http.StatusMethodNotAllowed.

func BadRequest

func BadRequest(w http.ResponseWriter, err error)

BadRequest sends an error response to with http.StatusNotAcceptable.

func Canceled

func Canceled(w http.ResponseWriter, err error)

Canceled sends an error response with StatusCanceled.

func DataLoss

func DataLoss(w http.ResponseWriter, err error)

Unknown sends an error response with StatusDataLoss.

func DeadlineExceeded

func DeadlineExceeded(w http.ResponseWriter, err error)

DeadlineExceeded sends an error response with StatusDeadlineExceeded.

func Exhausted

func Exhausted(w http.ResponseWriter, err error)

Exhausted sends an error response with http.StatusTooManyRequests.

func FailedPrecondition

func FailedPrecondition(w http.ResponseWriter, err error)

FailedPrecondition sends an error response with StatusFailedPrecondition.

func Forbidden

func Forbidden(w http.ResponseWriter, err error)

Forbidden sends an error response with http.StatusForbidden.

func InternalServerError

func InternalServerError(w http.ResponseWriter, err error)

InternalServerError sends an error response with http.StatusInternalServerError.

func NotFound

func NotFound(w http.ResponseWriter, _ error)

NotFound sends an error response with http.StatusNotFound.

func OK

func OK(w http.ResponseWriter, data interface{})

func OutOfRange

func OutOfRange(w http.ResponseWriter, err error)

OutOfRange sends an error response with http.StatusRequestedRangeNotSatisfiable.

func SystemError

func SystemError(w http.ResponseWriter, _ error)

SystemError responds with a generic error response if marshaling an APIResponse fails.

func Unauthenticated

func Unauthenticated(w http.ResponseWriter, err error)

Unauthenticated sends an error response with http.StatusUnauthorized.

func Unavailable

func Unavailable(w http.ResponseWriter, err error)

Unavailable sends an error response with http.StatusServiceUnavailable.

func Unimplemented

func Unimplemented(w http.ResponseWriter, err error)

Unimplemented sends an error response with http.StatusTooManyRequests.

func Unknown

func Unknown(w http.ResponseWriter, err error)

Unknown sends an error response with StatusUnknown.

Types

type ErrFunc

type ErrFunc func(http.ResponseWriter, error)

ErrFunc is a function that writes the given error to w.

type Response

type Response struct {
	// Arbitrary response data.
	Data interface{} `json:"data,omitempty"`

	// Non-empty if an error occurred.
	Error string `json:"error,omitempty"`
}

Response is a response from a SermoCRM microservice.

type T

type T struct{}

T implements grpc-ecosystem/grpc-gateway/runtime.Marshaler.

func (T) ContentType

func (t T) ContentType() string

ContentType implements grpc-ecosystem/grpc-gateway/runtime.Marshaler.

func (T) Marshal

func (t T) Marshal(v interface{}) ([]byte, error)

Marshal implements grpc-ecosystem/grpc-gateway/runtime.Marshaler.

func (T) NewDecoder

func (t T) NewDecoder(r io.Reader) runtime.Decoder

NewDecoder implements grpc-ecosystem/grpc-gateway/runtime.Marshaler.

func (T) NewEncoder

func (t T) NewEncoder(w io.Writer) runtime.Encoder

NewEncoder implements grpc-ecosystem/grpc-gateway/runtime.Marshaler.

func (T) Unmarshal

func (t T) Unmarshal(data []byte, v interface{}) error

Unmarshal implements grpc-ecosystem/grpc-gateway/runtime.Marshaler.

Jump to

Keyboard shortcuts

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