Documentation
¶
Index ¶
- Constants
- func DefaultLoggerConfig() zap.Config
- func ErrorHandler() func(context.Context, http.ResponseWriter, error)
- func HttpRequestIdMiddleware(next http.Handler) http.Handler
- func Logger(ctx context.Context) *zap.Logger
- func NewHttpServer(baseContext context.Context, mux goa.Muxer) *http.Server
- func NewInternalError() *goa.ServiceError
- func NewLogger() *zap.Logger
- func NewLoggerWithConfig(config zap.Config) *zap.Logger
- func NewStdErrorLogger(l *zap.Logger) *stdlog.Logger
- func RequestDecoderWithLogs(r *stdhttp.Request) http.Decoder
- func RequestEncoderWithLogs(r *stdhttp.Request) http.Encoder
- func ResponseDecoderFuncWithLogs(ctx context.Context) func(r *stdhttp.Response) http.Decoder
- func ResponseEncoderWithLogs(ctx context.Context, r stdhttp.ResponseWriter) http.Encoder
- func WithLogger(ctx context.Context, l *zap.Logger) context.Context
- type DecoderWithLogs
- type EncoderWithLogs
- type EndpointMiddleware
Constants ¶
const RequestIdKey key = "X-Request-Id"
RequestIdKey is the key used to store the request ID in the context or header.
Variables ¶
This section is empty.
Functions ¶
func DefaultLoggerConfig ¶
func ErrorHandler ¶
func ErrorHandler() func(context.Context, http.ResponseWriter, error)
func HttpRequestIdMiddleware ¶
HttpRequestIdMiddleware is a middleware that adds a unique request ID to the request context.
func Logger ¶
Logger extracts a zap logger from a context, providing a default logger if one is not present It's recommended that you do not change the logger config too much from the default because when you use this method we will not respect that configuration
func NewHttpServer ¶
NewHttpServer creates a new HTTP server with some default middlewares like HttpRequestIdMiddleware. You can of course update some config on the http.Server like timeouts or even replace the handler all together. This method expects that a http.Muxer with already mounted endpoints and endpoint middlewares.
By default, the server will use zap.Logger through the log.Logger wrapper to log errors.
func NewInternalError ¶
func NewInternalError() *goa.ServiceError
func NewLogger ¶
NewLogger returns a new zap logger. This logger is configured to log at InfoLevel and above We are using this logger instead of zap.NewProduction because by default it's configured to sample the logs Additionally, we this log will not fail to be created which simplifies what things could go wrong
func NewLoggerWithConfig ¶
NewLoggerWithConfig returns a new zap logger. This logger would use the config provided by the caller. You're only able to configure to set the JSON EncoderWithLogs and the level. The output is defaulted to stdout.
func ResponseEncoderWithLogs ¶
Types ¶
type DecoderWithLogs ¶
type DecoderWithLogs struct {
// contains filtered or unexported fields
}
func (DecoderWithLogs) Decode ¶
func (d DecoderWithLogs) Decode(v interface{}) error
type EncoderWithLogs ¶
type EncoderWithLogs struct {
// contains filtered or unexported fields
}
func (EncoderWithLogs) Encode ¶
func (e EncoderWithLogs) Encode(v interface{}) error
type EndpointMiddleware ¶
type EndpointMiddleware func(goa.Endpoint) goa.Endpoint // EndpointMiddleware are executed around the endpoint handler.
func EndpointLoggerInjectionMiddleware ¶
func EndpointLoggerInjectionMiddleware() EndpointMiddleware
EndpointLoggerInjectionMiddleware Injects the logger into the context with shared info of the request i.e. the request ID
func EndpointRecoverMiddleware ¶
func EndpointRecoverMiddleware() EndpointMiddleware
func EndpointRequestLogMiddleware ¶
func EndpointRequestLogMiddleware() EndpointMiddleware
EndpointRequestLogMiddleware waits for the request to complete logging the outcome of it.