service

package
v0.0.1-alpha.1 Latest Latest
Warning

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

Go to latest
Published: May 10, 2016 License: BSD-3-Clause Imports: 8 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 (
	ErrorInternalServerFailure = "internal-server-failure"
)
View Source
const (
	RequestEnvLogger = "logger"
)

Variables

View Source
var (
	InternalServerFailure = &Error{
		Code:   ErrorInternalServerFailure,
		Status: http.StatusInternalServerError,
		Detail: "Internal server failure",
		Title:  "internal server failure",
	}
)

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 WithContext

func WithContext(handler HandlerFunc) rest.HandlerFunc

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 struct {
	// contains filtered or unexported fields
}

func NewContext

func NewContext(response rest.ResponseWriter, request *rest.Request) *Context

func (*Context) Logger

func (c *Context) Logger() log.Logger

func (*Context) Request

func (c *Context) Request() *rest.Request

func (*Context) RespondWithError

func (c *Context) RespondWithError(err *Error)

func (*Context) RespondWithServerFailure

func (c *Context) RespondWithServerFailure(message string, failure ...interface{})

func (*Context) RespondWithStatusAndErrors

func (c *Context) RespondWithStatusAndErrors(statusCode int, errors []*Error)

func (*Context) Response

func (c *Context) Response() rest.ResponseWriter

type Error

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

func (*Error) WithParameter

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

func (*Error) WithPointer

func (e *Error) WithPointer(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) GetErrors

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

func (*Errors) HasErrors

func (e *Errors) HasErrors() bool

type HandlerFunc

type HandlerFunc func(context *Context)

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 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