Documentation ¶
Index ¶
- Constants
- func ClearFieldByName(obj interface{}, fieldName string) error
- func ClearFieldByType(obj interface{}, t reflect.Type) error
- func GetRequestID(ctx context.Context) string
- func Log(log LogFunc) xserver.Middleware
- func LogHandler(log LogFunc) routing.Handler
- func RequestID() xserver.Middleware
- type LogEntry
- type LogFunc
- type LogResponseStatusWriter
- type LogResponseWriter
Constants ¶
const RequestIdHttpHeader = "X-Request-ID"
const RequestIdKey requestIdCxtKey = 0
RequestIdKey is the key to store an unique request ID in a request context.
Variables ¶
This section is empty.
Functions ¶
func ClearFieldByName ¶
ClearFieldByName clears all fields and nested fields in an object that have a specified name.
func ClearFieldByType ¶
ClearFieldByType clears all fields and nested fields in an object that have a specified type.
func GetRequestID ¶
GetRequestID returns a request ID for the given context; otherwise an empty string will be returned if the context is nil or the request ID can not be found.
func Log ¶
func Log(log LogFunc) xserver.Middleware
Log creates a middleware to log HTTP requests and responses.
func LogHandler ¶
func LogHandler(log LogFunc) routing.Handler
LogHandler creates a middleware handler for logging HTTP requests and responses
func RequestID ¶
func RequestID() xserver.Middleware
RequestID creates a middleware which creates a request ID and store the ID in the request context.
Types ¶
type LogFunc ¶
type LogFunc func(r *http.Request, w *LogResponseWriter, elapsed time.Duration)
LogFunc represents the func header for logging HTTP requests and responses on a middleware.
func NewLogger ¶
func NewLogger(timeFormat string, pathsToIgnore []string, logFunc func(entity LogEntry, values ...interface{})) LogFunc
NewLogger returns a new Logger based on APIKit middleware.LogFunc by recognizing the given time format.
func NewMaskingLogger ¶
func NewMaskingLogger(timeFormat string, fieldsToMask []string, typesToMask []reflect.Type, pathsToIgnore []string, logFunc func(logEntry LogEntry, values ...interface{})) LogFunc
NewMaskingLogger returns a new Logger based on APIKit middleware.LogFunc that will mask the body content of HTTP requests and responses for a given array of field names and types.
type LogResponseStatusWriter ¶
type LogResponseStatusWriter struct { http.ResponseWriter Status int }
func NewLogResponseStatusWriter ¶
func NewLogResponseStatusWriter(w http.ResponseWriter) *LogResponseStatusWriter
func (*LogResponseStatusWriter) WriteHeader ¶
func (r *LogResponseStatusWriter) WriteHeader(status int)
type LogResponseWriter ¶
type LogResponseWriter struct { LogResponseStatusWriter BytesWritten int64 Body []byte }
LogResponseWriter represents a http.ResponseWriter with additional functionality to store response related data for a later use.
func NewLogResponseWriter ¶
func NewLogResponseWriter(w http.ResponseWriter) *LogResponseWriter