accesslog

package
v0.1.21 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 28, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FilterHeaders

func FilterHeaders(h http.Header) string

func FilterHeadersWithAdditionalSensitiveHeaders

func FilterHeadersWithAdditionalSensitiveHeaders(h http.Header, headers ...string) string

func FilterHeadersWithSensitiveHeaders

func FilterHeadersWithSensitiveHeaders(h http.Header, headers ...string) string

func GetRequestBody

func GetRequestBody(c *gin.Context) (map[string]interface{}, error)

GetRequestBody 提取请求体,按 Content-Type 解析为 map

func GetRequestHeaders

func GetRequestHeaders(c *gin.Context) map[string]interface{}

GetRequestHeaders 提取请求头为 map

func GetRequestQuery

func GetRequestQuery(c *gin.Context) map[string]interface{}

GetRequestQuery 提取 URL 查询参数为 map

func IsSkipped

func IsSkipped(c *gin.Context) bool

IsSkipped reports whether current Gin request is marked to skip access logging.

func Middleware

func Middleware(source string, opts ...MiddlewareOption) gin.HandlerFunc

Middleware records HTTP request and response metadata. The logger is optional so services can opt in with WithLogger.

func RequestInputs

func RequestInputs(c *gin.Context) (map[string]interface{}, error)

RequestInputs 分离 GET 查询参数和 POST 请求体

func Skip

func Skip(c *gin.Context)

Skip marks current Gin request as skipped by accesslog middleware.

Types

type Actor

type Actor = coreaccesslog.Actor

type ActorResolver

type ActorResolver func(*gin.Context) Actor

type Config

type Config = coreaccesslog.Config

type Entry

type Entry = coreaccesslog.Entry

type Logger

type Logger = coreaccesslog.Logger

func NewLogger

func NewLogger(writer Writer, cfg Config) *Logger

type MiddlewareOption

type MiddlewareOption func(*middlewareConfig)

func WithActorResolver

func WithActorResolver(resolver ActorResolver) MiddlewareOption

func WithAdditionalSensitiveFields

func WithAdditionalSensitiveFields(fields ...string) MiddlewareOption

WithAdditionalSensitiveFields appends body field keywords to the default redaction list.

func WithAdditionalSensitiveHeaders

func WithAdditionalSensitiveHeaders(headers ...string) MiddlewareOption

WithAdditionalSensitiveHeaders appends request header names to the default filter list.

func WithLogger

func WithLogger(logger *Logger) MiddlewareOption

func WithSensitiveFields

func WithSensitiveFields(fields ...string) MiddlewareOption

WithSensitiveFields replaces body field redaction keywords. Passing no fields disables body field redaction for this middleware.

func WithSensitiveHeaders

func WithSensitiveHeaders(headers ...string) MiddlewareOption

WithSensitiveHeaders replaces request header filter names. Passing no headers disables header filtering for this middleware.

func WithSkipIPs

func WithSkipIPs(values ...string) MiddlewareOption

WithSkipIPs skips access logging for matched client IPs. Values support exact IPs such as "127.0.0.1" and CIDR ranges such as "10.0.0.0/8".

func WithSkipMethods

func WithSkipMethods(methods ...string) MiddlewareOption

WithSkipMethods skips access logging for matched HTTP methods.

func WithSkipper

func WithSkipper(skipper Skipper) MiddlewareOption

type Skipper

type Skipper func(*gin.Context) bool

type Writer

type Writer = coreaccesslog.Writer

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL