Documentation ¶
Index ¶
- Constants
- func AnnotateTracerProvider(base oteltrace.TracerProvider) oteltrace.TracerProvider
- func CtxLogger(c echo.Context) *log.Logger
- func CtxRequestId(c echo.Context) string
- func CtxTracer(c echo.Context) oteltrace.Tracer
- func JsonErrorHandler(obfuscate bool, stack bool) echo.HTTPErrorHandler
- func MatchPrefix(prefixes []string, str string) bool
- type CtxRequestIdKey
- type DefaultHttpServerFactory
- type EchoLogger
- func (e *EchoLogger) Debug(i ...interface{})
- func (e *EchoLogger) Debugf(format string, args ...interface{})
- func (e *EchoLogger) Debugj(j echologger.JSON)
- func (e *EchoLogger) Error(i ...interface{})
- func (e *EchoLogger) Errorf(format string, args ...interface{})
- func (e *EchoLogger) Errorj(j echologger.JSON)
- func (e *EchoLogger) Fatal(i ...interface{})
- func (e *EchoLogger) Fatalf(format string, args ...interface{})
- func (e *EchoLogger) Fatalj(j echologger.JSON)
- func (e *EchoLogger) Info(i ...interface{})
- func (e *EchoLogger) Infof(format string, args ...interface{})
- func (e *EchoLogger) Infoj(j echologger.JSON)
- func (e *EchoLogger) Level() echologger.Lvl
- func (e *EchoLogger) Output() io.Writer
- func (e *EchoLogger) Panic(i ...interface{})
- func (e *EchoLogger) Panicf(format string, args ...interface{})
- func (e *EchoLogger) Panicj(j echologger.JSON)
- func (e *EchoLogger) Prefix() string
- func (e *EchoLogger) Print(i ...interface{})
- func (e *EchoLogger) Printf(format string, i ...interface{})
- func (e *EchoLogger) Printj(j echologger.JSON)
- func (e *EchoLogger) SetHeader(h string)
- func (e *EchoLogger) SetLevel(v echologger.Lvl)
- func (e *EchoLogger) SetOutput(w io.Writer)
- func (e *EchoLogger) SetPrefix(p string)
- func (e *EchoLogger) ToZerolog() *zerolog.Logger
- func (e *EchoLogger) Warn(i ...interface{})
- func (e *EchoLogger) Warnf(format string, args ...interface{})
- func (e *EchoLogger) Warnj(j echologger.JSON)
- type HtmlTemplateRenderer
- type HttpServerFactory
- type HttpServerOption
- func WithBanner(b bool) HttpServerOption
- func WithBinder(b echo.Binder) HttpServerOption
- func WithDebug(d bool) HttpServerOption
- func WithHttpErrorHandler(h echo.HTTPErrorHandler) HttpServerOption
- func WithJsonSerializer(s echo.JSONSerializer) HttpServerOption
- func WithLogger(l echo.Logger) HttpServerOption
- func WithRenderer(r echo.Renderer) HttpServerOption
- type Options
- type TracerProviderRequestIdAnnotator
- func (a *TracerProviderRequestIdAnnotator) ForceFlush(context.Context) error
- func (a *TracerProviderRequestIdAnnotator) OnEnd(otelsdktrace.ReadOnlySpan)
- func (a *TracerProviderRequestIdAnnotator) OnStart(ctx context.Context, s otelsdktrace.ReadWriteSpan)
- func (a *TracerProviderRequestIdAnnotator) Shutdown(context.Context) error
Constants ¶
const TraceSpanAttributeHttpRequestId = "guid:x-request-id"
TraceSpanAttributeHttpRequestId is a span attribute representing the request id.
const TracerName = "httpserver"
TracerName is the httpserver tracer name.
Variables ¶
This section is empty.
Functions ¶
func AnnotateTracerProvider ¶
func AnnotateTracerProvider(base oteltrace.TracerProvider) oteltrace.TracerProvider
AnnotateTracerProvider extend adds the TracerProviderRequestIdAnnotator span processor to the provided oteltrace.TracerProvider.
func CtxLogger ¶
CtxRequestId returns the contextual log.Logger.
func CtxRequestId ¶
func CtxRequestId(c echo.Context) string
CtxRequestId returns the contextual request id.
func JsonErrorHandler ¶
JsonErrorHandler is an echo.HTTPErrorHandler that outputs errors in JSON format. It can also be configured to obfuscate error message (to avoid to leak sensitive details), and to add the error stack to the response.
func MatchPrefix ¶
MatchPrefix returns true if a given prefix matches an item of a given prefixes list.
Types ¶
type DefaultHttpServerFactory ¶
type DefaultHttpServerFactory struct{}
DefaultHttpServerFactory is the default HttpServerFactory implementation.
func (*DefaultHttpServerFactory) Create ¶
func (f *DefaultHttpServerFactory) Create(options ...HttpServerOption) (*echo.Echo, error)
Create returns a new echo.Echo, and accepts a list of HttpServerOption. For example:
var server, _ = httpserver.NewDefaultHttpServerFactory().Create()
is equivalent to:
var server, _ = httpserver.NewDefaultHttpServerFactory().Create( httpserver.WithDebug(false), // debug disabled by default httpserver.WithBanner(false), // banner disabled by default httpserver.WithLogger(log.New("default")), // echo default logger httpserver.WithBinder(&echo.DefaultBinder{}), // echo default binder httpserver.WithJsonSerializer(&echo.DefaultJSONSerializer{}), // echo default json serializer httpserver.WithHttpErrorHandler(nil), // echo default error handler )
type EchoLogger ¶
type EchoLogger struct {
// contains filtered or unexported fields
}
EchoLogger is a log.Logger wrapper for echo.Logger compatibility.
func NewEchoLogger ¶
func NewEchoLogger(logger *log.Logger) *EchoLogger
NewEchoLogger returns a new log.Logger.
func (*EchoLogger) Debug ¶
func (e *EchoLogger) Debug(i ...interface{})
Debug produces a log with debug level.
func (*EchoLogger) Debugf ¶
func (e *EchoLogger) Debugf(format string, args ...interface{})
Debugf produces a formatted log with debug level.
func (*EchoLogger) Debugj ¶
func (e *EchoLogger) Debugj(j echologger.JSON)
Debugj produces a json log with debug level.
func (*EchoLogger) Error ¶
func (e *EchoLogger) Error(i ...interface{})
Error produces a log with error level.
func (*EchoLogger) Errorf ¶
func (e *EchoLogger) Errorf(format string, args ...interface{})
Errorf produces a formatted log with error level.
func (*EchoLogger) Errorj ¶
func (e *EchoLogger) Errorj(j echologger.JSON)
Errorj produces a json log with error level.
func (*EchoLogger) Fatal ¶
func (e *EchoLogger) Fatal(i ...interface{})
Fatal produces a log with fatal level.
func (*EchoLogger) Fatalf ¶
func (e *EchoLogger) Fatalf(format string, args ...interface{})
Fatalf produces a formatted log with fatal level.
func (*EchoLogger) Fatalj ¶
func (e *EchoLogger) Fatalj(j echologger.JSON)
Fatalj produces a json log with fatal level.
func (*EchoLogger) Info ¶
func (e *EchoLogger) Info(i ...interface{})
Info produces a log with info level.
func (*EchoLogger) Infof ¶
func (e *EchoLogger) Infof(format string, args ...interface{})
Infof produces a formatted log with info level.
func (*EchoLogger) Infoj ¶
func (e *EchoLogger) Infoj(j echologger.JSON)
Infoj produces a json log with info level.
func (*EchoLogger) Output ¶
func (e *EchoLogger) Output() io.Writer
Output returns the output writer.
func (*EchoLogger) Panic ¶
func (e *EchoLogger) Panic(i ...interface{})
Panic produces a log with panic level.
func (*EchoLogger) Panicf ¶
func (e *EchoLogger) Panicf(format string, args ...interface{})
Panicf produces a formatted log with panic level.
func (*EchoLogger) Panicj ¶
func (e *EchoLogger) Panicj(j echologger.JSON)
Panicj produces a json log with panic level.
func (*EchoLogger) Print ¶
func (e *EchoLogger) Print(i ...interface{})
Print produces a log with no level.
func (*EchoLogger) Printf ¶
func (e *EchoLogger) Printf(format string, i ...interface{})
Printf produces a formatted log with no level.
func (*EchoLogger) Printj ¶
func (e *EchoLogger) Printj(j echologger.JSON)
Printj produces a json log with no level.
func (*EchoLogger) SetHeader ¶
func (e *EchoLogger) SetHeader(h string)
SetHeader sets the log header field.
func (*EchoLogger) SetLevel ¶
func (e *EchoLogger) SetLevel(v echologger.Lvl)
SetLevel sets the log level.
func (*EchoLogger) SetOutput ¶
func (e *EchoLogger) SetOutput(w io.Writer)
SetOutput sets the output writer.
func (*EchoLogger) SetPrefix ¶
func (e *EchoLogger) SetPrefix(p string)
SetPrefix sets the log prefix.
func (*EchoLogger) ToZerolog ¶
func (e *EchoLogger) ToZerolog() *zerolog.Logger
ToZerolog converts new log.Logger to a zerolog.Logger.
func (*EchoLogger) Warn ¶
func (e *EchoLogger) Warn(i ...interface{})
Warn produces a log with warn level.
func (*EchoLogger) Warnf ¶
func (e *EchoLogger) Warnf(format string, args ...interface{})
Warnf produces a formatted log with warn level.
func (*EchoLogger) Warnj ¶
func (e *EchoLogger) Warnj(j echologger.JSON)
Warnj produces a json log with warn level.
type HtmlTemplateRenderer ¶
type HtmlTemplateRenderer struct {
// contains filtered or unexported fields
}
HtmlTemplateRenderer allows to render HTML templates, based on html/template.
func NewHtmlTemplateRenderer ¶
func NewHtmlTemplateRenderer(pattern string) *HtmlTemplateRenderer
NewHtmlTemplateRenderer returns a HtmlTemplateRenderer, for a file pattern.
type HttpServerFactory ¶
type HttpServerFactory interface {
Create(options ...HttpServerOption) (*echo.Echo, error)
}
HttpServerFactory is the interface for echo.Echo factories.
func NewDefaultHttpServerFactory ¶
func NewDefaultHttpServerFactory() HttpServerFactory
NewDefaultHttpServerFactory returns a DefaultHttpServerFactory, implementing HttpServerFactory.
type HttpServerOption ¶
type HttpServerOption func(o *Options)
HttpServerOption are functional options for the HttpServerFactory implementations.
func WithBanner ¶
func WithBanner(b bool) HttpServerOption
WithBanner is used to activate the server banner.
func WithBinder ¶
func WithBinder(b echo.Binder) HttpServerOption
WithBinder is used to specify a echo.Binder to be used by the server.
func WithDebug ¶
func WithDebug(d bool) HttpServerOption
WithDebug is used to activate the server debug mode.
func WithHttpErrorHandler ¶
func WithHttpErrorHandler(h echo.HTTPErrorHandler) HttpServerOption
WithHttpErrorHandler is used to specify a echo.HTTPErrorHandler to be used by the server.
func WithJsonSerializer ¶
func WithJsonSerializer(s echo.JSONSerializer) HttpServerOption
WithJsonSerializer is used to specify a echo.JSONSerializer to be used by the server.
func WithLogger ¶
func WithLogger(l echo.Logger) HttpServerOption
WithLogger is used to specify a echo.Logger to be used by the server.
func WithRenderer ¶
func WithRenderer(r echo.Renderer) HttpServerOption
WithRenderer is used to specify a echo.Renderer to be used by the server.
type Options ¶
type Options struct { Debug bool Banner bool Logger echo.Logger Binder echo.Binder JsonSerializer echo.JSONSerializer HttpErrorHandler echo.HTTPErrorHandler Renderer echo.Renderer }
Options are options for the HttpServerFactory implementations.
func DefaultHttpServerOptions ¶
func DefaultHttpServerOptions() Options
DefaultHttpServerOptions are the default options used in the DefaultHttpServerFactory.
type TracerProviderRequestIdAnnotator ¶
type TracerProviderRequestIdAnnotator struct{}
TracerProviderRequestIdAnnotator is a span processor to add the contextual request id as span attribute.
func NewTracerProviderRequestIdAnnotator ¶
func NewTracerProviderRequestIdAnnotator() *TracerProviderRequestIdAnnotator
NewTracerProviderRequestIdAnnotator returns a new TracerProviderRequestIdAnnotator.
func (*TracerProviderRequestIdAnnotator) ForceFlush ¶
func (a *TracerProviderRequestIdAnnotator) ForceFlush(context.Context) error
ForceFlush performs no operations.
func (*TracerProviderRequestIdAnnotator) OnEnd ¶
func (a *TracerProviderRequestIdAnnotator) OnEnd(otelsdktrace.ReadOnlySpan)
OnEnd performs no operations.
func (*TracerProviderRequestIdAnnotator) OnStart ¶
func (a *TracerProviderRequestIdAnnotator) OnStart(ctx context.Context, s otelsdktrace.ReadWriteSpan)
OnStart adds the contextual request id as span attribute.