service

package
v0.0.1-alpha.5 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2016 License: BSD-3-Clause Imports: 9 Imported by: 24

Documentation

Index

Constants

View Source
const (
	LogErrors           = "errors"
	LogMethod           = "method"
	LogProto            = "proto"
	LogRefererer        = "referrer"
	LogRemoteAddress    = "remote-address"
	LogRemoteUser       = "remote-user"
	LogRequestURI       = "request-uri"
	LogResponseBytes    = "response-bytes"
	LogResponseDuration = "response-duration"
	LogStartTime        = "start-time"
	LogStatusCode       = "status-code"
	LogUserAgent        = "user-agent"

	RequestEnvBytesWritten = "BYTE_WRITTEN"
	RequestEnvElapsedTime  = "ELAPSED_TIME"
	RequestEnvErrors       = "ERRORS"
	RequestEnvRemoteUser   = "REMOTE_USER"
	RequestEnvStartTime    = "START_TIME"
	RequestEnvStatusCode   = "STATUS_CODE"
)
View Source
const (
	HTTPHeaderTraceRequest = "X-Tidepool-Trace-Request"
	HTTPHeaderTraceSession = "X-Tidepool-Trace-Session"

	LogTraceRequest = "trace-request"
	LogTraceSession = "trace-session"

	RequestEnvTraceRequest = "trace-request"
	RequestEnvTraceSession = "trace-session"

	TraceSessionMaximumLength = 64
)
View Source
const (
	RequestEnvLogger = "logger"
)

Variables

This section is empty.

Functions

func CopyRequestTrace

func CopyRequestTrace(sourceRequest *rest.Request, destinationRequest *http.Request) error

func GetRequestLogger

func GetRequestLogger(request *rest.Request) log.Logger

func GetRequestTraceRequest

func GetRequestTraceRequest(request *rest.Request) string

func GetRequestTraceSession

func GetRequestTraceSession(request *rest.Request) string

func QuoteIfString added in v1.20.0

func QuoteIfString(interfaceValue interface{}) interface{}

Types

type AccessLogMiddleware

type AccessLogMiddleware struct{}

func NewAccessLogMiddleware

func NewAccessLogMiddleware() (*AccessLogMiddleware, error)

func (*AccessLogMiddleware) MiddlewareFunc

func (l *AccessLogMiddleware) MiddlewareFunc(handler rest.HandlerFunc) rest.HandlerFunc

type Context

type Context interface {
	Logger() log.Logger

	Request() *rest.Request
	Response() rest.ResponseWriter

	RespondWithError(err *Error)
	RespondWithInternalServerFailure(message string, failure ...interface{})
	RespondWithStatusAndErrors(statusCode int, errors []*Error)
}

type Error

type Error struct {
	Code   string      `json:"code,omitempty"`
	Title  string      `json:"title,omitempty"`
	Detail string      `json:"detail,omitempty"`
	Status int         `json:"status,string,omitempty"`
	Source *Source     `json:"source,omitempty"`
	Meta   interface{} `json:"meta,omitempty"`
}

func ErrorInternalServerFailure

func ErrorInternalServerFailure() *Error

func (*Error) WithMeta

func (e *Error) WithMeta(meta interface{}) *Error

func (*Error) WithSourceParameter

func (e *Error) WithSourceParameter(parameter string) *Error

func (*Error) WithSourcePointer

func (e *Error) WithSourcePointer(pointer string) *Error

type Errors

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

func NewErrors

func NewErrors() *Errors

func (*Errors) AppendError

func (e *Errors) AppendError(err *Error)

func (*Errors) GetError

func (e *Errors) GetError(index int) *Error

func (*Errors) GetErrors

func (e *Errors) GetErrors() []*Error

func (*Errors) HasErrors

func (e *Errors) HasErrors() bool

type JSONResponse

type JSONResponse struct {
	Errors []*Error `json:"errors,omitempty"`
	Meta   *Meta    `json:"meta,omitempty"`
}

type LoggerMiddleware

type LoggerMiddleware struct {
	Logger log.Logger
}

func NewLoggerMiddleware

func NewLoggerMiddleware(logger log.Logger) (*LoggerMiddleware, error)

func (*LoggerMiddleware) MiddlewareFunc

func (l *LoggerMiddleware) MiddlewareFunc(handler rest.HandlerFunc) rest.HandlerFunc

type Meta added in v1.20.0

type Meta struct {
	Trace *Trace `json:"trace,omitempty"`
}

type RecoverMiddleware

type RecoverMiddleware struct{}

func NewRecoverMiddleware

func NewRecoverMiddleware() (*RecoverMiddleware, error)

func (*RecoverMiddleware) MiddlewareFunc

func (r *RecoverMiddleware) MiddlewareFunc(handler rest.HandlerFunc) rest.HandlerFunc

type Source

type Source struct {
	Parameter string `json:"parameter,omitempty"`
	Pointer   string `json:"pointer,omitempty"`
}

type Standard

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

func NewStandard

func NewStandard(response rest.ResponseWriter, request *rest.Request) *Standard

func (*Standard) Logger

func (s *Standard) Logger() log.Logger

func (*Standard) Request

func (s *Standard) Request() *rest.Request

func (*Standard) RespondWithError

func (s *Standard) RespondWithError(err *Error)

func (*Standard) RespondWithInternalServerFailure

func (s *Standard) RespondWithInternalServerFailure(message string, failure ...interface{})

func (*Standard) RespondWithStatusAndErrors

func (s *Standard) RespondWithStatusAndErrors(statusCode int, errors []*Error)

func (*Standard) Response

func (s *Standard) Response() rest.ResponseWriter

type Trace added in v1.20.0

type Trace struct {
	Request string `json:"request,omitempty"`
	Session string `json:"session,omitempty"`
}

type TraceMiddleware

type TraceMiddleware struct{}

func NewTraceMiddleware

func NewTraceMiddleware() (*TraceMiddleware, error)

func (*TraceMiddleware) MiddlewareFunc

func (l *TraceMiddleware) MiddlewareFunc(handler rest.HandlerFunc) rest.HandlerFunc

Jump to

Keyboard shortcuts

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