handler

package
v0.4.5 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2018 License: Apache-2.0 Imports: 15 Imported by: 35

Documentation

Index

Constants

View Source
const (
	// WarningsHeader is the M3 warnings header when to display a warning to a user
	WarningsHeader = "M3-Warnings"

	// RetryHeader is the M3 retry header to display when it is safe to retry
	RetryHeader = "M3-Retry"

	// ServedByHeader is the M3 query storage execution breakdown
	ServedByHeader = "M3-Storage-By"

	// DeprecatedHeader is the M3 deprecated header
	DeprecatedHeader = "M3-Deprecated"
)
View Source
const (
	// SearchURL is the url to search for metric ids
	SearchURL = "/search"

	// SearchHTTPMethod is the HTTP method used with this resource.
	SearchHTTPMethod = http.MethodPost
)

Variables

View Source
var (
	// ErrInvalidParams is returned when input parameters are invalid
	ErrInvalidParams = errors.New("invalid request params")
)

Functions

func CloseWatcher

func CloseWatcher(ctx context.Context, w http.ResponseWriter) (<-chan bool, <-chan bool)

CloseWatcher watches for CloseNotify and context timeout. It is best effort and may sometimes not close the channel relying on gc

func DurationToNanosBytes

func DurationToNanosBytes(r io.Reader) ([]byte, error)

DurationToNanosBytes transforms a json byte slice with Duration keys into Nanos

func DurationToNanosMap

func DurationToNanosMap(input map[string]interface{}) (map[string]interface{}, error)

DurationToNanosMap transforms keys with a Duration into Nanos

func Error

func Error(w http.ResponseWriter, err error, code int)

Error will serve an HTTP error

func IsInvalidParams

func IsInvalidParams(err error) bool

IsInvalidParams returns true if this is an invalid params error

func NewSearchHandler

func NewSearchHandler(storage storage.Storage) http.Handler

NewSearchHandler returns a new instance of handler

func WriteJSONResponse

func WriteJSONResponse(w http.ResponseWriter, data interface{}, logger *zap.Logger)

WriteJSONResponse writes generic data to the ResponseWriter

func WriteProtoMsgJSONResponse

func WriteProtoMsgJSONResponse(w http.ResponseWriter, data proto.Message, logger *zap.Logger)

WriteProtoMsgJSONResponse writes a protobuf message to the ResponseWriter. This uses jsonpb for json marshalling, which encodes fields with default values, even with the omitempty tag.

func WriteUninitializedResponse

func WriteUninitializedResponse(w http.ResponseWriter, logger *zap.Logger)

WriteUninitializedResponse writes a protobuf message to the ResponseWriter

Types

type HeaderKeyType added in v0.4.5

type HeaderKeyType int

HeaderKeyType is the type for the header key

const (
	// RoutePrefixV1 is the v1 prefix for all coordinator routes
	RoutePrefixV1 = "/api/v1"

	// HeaderKey is the key which headers will be added to in the request context
	HeaderKey HeaderKeyType = iota
)

type ParseError

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

ParseError is the error from parsing requests

func NewParseError

func NewParseError(inner error, code int) *ParseError

NewParseError creates a new parse error

func (*ParseError) Code

func (e *ParseError) Code() int

Code returns the parse error type

func (*ParseError) Error

func (e *ParseError) Error() string

Error returns the error string

func (*ParseError) Inner

func (e *ParseError) Inner() error

Inner returns the error object

type SearchHandler

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

SearchHandler represents a handler for the search endpoint

func (*SearchHandler) ServeHTTP

func (h *SearchHandler) ServeHTTP(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