Documentation ¶
Index ¶
- Variables
- func AddCustomAttributes(c echo.Context, attr slog.Attr)
- func New(logger *slog.Logger) echo.MiddlewareFunc
- func NewWithConfig(logger *slog.Logger, config Config) echo.MiddlewareFunc
- func NewWithFilters(logger *slog.Logger, filters ...Filter) echo.MiddlewareFunc
- type Config
- type Filter
- func AcceptHost(hosts ...string) Filter
- func AcceptHostContains(parts ...string) Filter
- func AcceptHostMatch(regs ...regexp.Regexp) Filter
- func AcceptHostPrefix(prefixs ...string) Filter
- func AcceptHostSuffix(prefixs ...string) Filter
- func AcceptMethod(methods ...string) Filter
- func AcceptPath(urls ...string) Filter
- func AcceptPathContains(parts ...string) Filter
- func AcceptPathMatch(regs ...regexp.Regexp) Filter
- func AcceptPathPrefix(prefixs ...string) Filter
- func AcceptPathSuffix(prefixs ...string) Filter
- func AcceptStatus(statuses ...int) Filter
- func AcceptStatusGreaterThan(status int) Filter
- func AcceptStatusGreaterThanOrEqual(status int) Filter
- func IgnoreHost(hosts ...string) Filter
- func IgnoreHostContains(parts ...string) Filter
- func IgnoreHostMatch(regs ...regexp.Regexp) Filter
- func IgnoreHostPrefix(prefixs ...string) Filter
- func IgnoreHostSuffix(suffixs ...string) Filter
- func IgnoreMethod(methods ...string) Filter
- func IgnorePath(urls ...string) Filter
- func IgnorePathContains(parts ...string) Filter
- func IgnorePathMatch(regs ...regexp.Regexp) Filter
- func IgnorePathPrefix(prefixs ...string) Filter
- func IgnorePathSuffix(suffixs ...string) Filter
- func IgnoreStatus(statuses ...int) Filter
- func IgnoreStatusLessThan(status int) Filter
- func IgnoreStatusLessThanOrEqual(status int) Filter
Constants ¶
This section is empty.
Variables ¶
var ( RequestBodyMaxSize = 64 * 1024 // 64KB ResponseBodyMaxSize = 64 * 1024 // 64KB HiddenRequestHeaders = map[string]struct{}{ "authorization": {}, "cookie": {}, "set-cookie": {}, "x-auth-token": {}, "x-csrf-token": {}, "x-xsrf-token": {}, } HiddenResponseHeaders = map[string]struct{}{ "set-cookie": {}, } )
custom var
Functions ¶
func AddCustomAttributes ¶
AddCustomAttributes adds custom slog.Attr
func New ¶
New returns a echo.MiddlewareFunc (middleware) that logs requests using slog.
Requests with errors are logged using slog.Error(). Requests without errors are logged using slog.Info().
func NewWithConfig ¶
NewWithConfig returns a echo.HandlerFunc (middleware) that logs requests using slog.
func NewWithFilters ¶
NewWithFilters returns a echo.MiddlewareFunc (middleware) that logs requests using slog.
Requests with errors are logged using slog.Error(). Requests without errors are logged using slog.Info().
Types ¶
type Config ¶
type Config struct { DefaultLevel slog.Level ClientErrorLevel slog.Level ServerErrorLevel slog.Level WithUserAgent bool WithRequestID bool WithRequestBody bool WithRequestHeader bool WithResponseBody bool WithResponseHeader bool WithSpanID bool WithTraceID bool Filters []Filter }
Config provide configurations
type Filter ¶
type Filter func(ctx echo.Context) bool
Filter is core filter
func AcceptHostContains ¶
AcceptHostContains filters allow host contains
func AcceptHostMatch ¶
AcceptHostMatch filter allow by host matched regex
func AcceptHostPrefix ¶
AcceptHostPrefix filters allow host by prefix
func AcceptHostSuffix ¶
AcceptHostSuffix filters allow by host suffix
func AcceptMethod ¶
AcceptMethod filters allow by method
func AcceptPathContains ¶
AcceptPathContains filters allow by path contains
func AcceptPathMatch ¶
AcceptPathMatch filters allow by path matched regexp
func AcceptPathPrefix ¶
AcceptPathPrefix filters allow by path prefix
func AcceptPathSuffix ¶
AcceptPathSuffix filters allow by path suffix
func AcceptStatusGreaterThan ¶
AcceptStatusGreaterThan filters allow by status gt
func AcceptStatusGreaterThanOrEqual ¶
AcceptStatusGreaterThanOrEqual filters allow by status gte
func IgnoreHostContains ¶
IgnoreHostContains filters disallow host contains
func IgnoreHostMatch ¶
IgnoreHostMatch filter disallow by host matched regex
func IgnoreHostPrefix ¶
IgnoreHostPrefix filters disallow host by prefix
func IgnoreHostSuffix ¶
IgnoreHostSuffix filters disallow by host suffix
func IgnoreMethod ¶
IgnoreMethod filters disallow by method
func IgnorePathContains ¶
IgnorePathContains filters disallow by path contains
func IgnorePathMatch ¶
IgnorePathMatch filters disallow by path matched regexp
func IgnorePathPrefix ¶
IgnorePathPrefix filters disallow by path prefix
func IgnorePathSuffix ¶
IgnorePathSuffix filters disallow by path suffix
func IgnoreStatus ¶
IgnoreStatus filters disallow by status
func IgnoreStatusLessThan ¶
IgnoreStatusLessThan filters disallow by status lt
func IgnoreStatusLessThanOrEqual ¶
IgnoreStatusLessThanOrEqual filters disallow by status lte