Documentation ¶
Index ¶
- Constants
- Variables
- func CopyRequestTrace(sourceRequest *rest.Request, destinationRequest *http.Request) error
- func GetRequestLogger(request *rest.Request) log.Logger
- func GetRequestTraceRequest(request *rest.Request) string
- func GetRequestTraceSession(request *rest.Request) string
- func WithContext(handler HandlerFunc) rest.HandlerFunc
- type AccessLogMiddleware
- type Context
- func (c *Context) Logger() log.Logger
- func (c *Context) Request() *rest.Request
- func (c *Context) RespondWithError(err *Error)
- func (c *Context) RespondWithServerFailure(message string, failure ...interface{})
- func (c *Context) RespondWithStatusAndErrors(statusCode int, errors []*Error)
- func (c *Context) Response() rest.ResponseWriter
- type Error
- type Errors
- type HandlerFunc
- type JSONResponse
- type LoggerMiddleware
- type Meta
- type RecoverMiddleware
- type Source
- type Trace
- type TraceMiddleware
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 GetRequestTraceRequest ¶
func GetRequestTraceSession ¶
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) RespondWithError ¶
func (*Context) RespondWithServerFailure ¶
func (*Context) RespondWithStatusAndErrors ¶
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 (*Error) WithPointer ¶
type Errors ¶
type Errors struct {
// contains filtered or unexported fields
}
func (*Errors) AppendError ¶
type HandlerFunc ¶
type HandlerFunc func(context *Context)
type JSONResponse ¶
type LoggerMiddleware ¶
func NewLoggerMiddleware ¶
func NewLoggerMiddleware(logger log.Logger) (*LoggerMiddleware, error)
func (*LoggerMiddleware) MiddlewareFunc ¶
func (l *LoggerMiddleware) MiddlewareFunc(handler rest.HandlerFunc) rest.HandlerFunc
type RecoverMiddleware ¶
type RecoverMiddleware struct{}
func NewRecoverMiddleware ¶
func NewRecoverMiddleware() (*RecoverMiddleware, error)
func (*RecoverMiddleware) MiddlewareFunc ¶
func (r *RecoverMiddleware) MiddlewareFunc(handler rest.HandlerFunc) rest.HandlerFunc
type TraceMiddleware ¶
type TraceMiddleware struct{}
func NewTraceMiddleware ¶
func NewTraceMiddleware() (*TraceMiddleware, error)
func (*TraceMiddleware) MiddlewareFunc ¶
func (l *TraceMiddleware) MiddlewareFunc(handler rest.HandlerFunc) rest.HandlerFunc
Click to show internal directories.
Click to hide internal directories.