Documentation
¶
Index ¶
- Constants
- Variables
- func AccessLog(req *restful.Request, resp *restful.Response, chain *restful.FilterChain)
- func Attribute(option Option) restful.FilterFunction
- func MaskFields(contentType, content, fields string) string
- func MaskQueryParams(uri string, fields string) string
- type FieldRegex
- type Option
- type ResponseWriterInterceptor
Constants ¶
const ( MaskedQueryParamsAttribute = "MaskedQueryParams" MaskedRequestFieldsAttribute = "MaskedRequestFields" MaskedResponseFieldsAttribute = "MaskedResponseFields" UserIDAttribute = "LogUserId" ClientIDAttribute = "LogClientId" NamespaceAttribute = "LogNamespace" )
const (
MaskedValue = "******"
)
Variables ¶
var ( FullAccessLogEnabled bool FullAccessLogSupportedContentTypes []string FullAccessLogMaxBodySize int FullAccessLogRequestBodyEnabled bool FullAccessLogResponseBodyEnabled bool )
var FieldRegexCache = sync.Map{}
Functions ¶
func AccessLog ¶ added in v4.10.0
func AccessLog(req *restful.Request, resp *restful.Response, chain *restful.FilterChain)
AccessLog is a filter that will log incoming request into the Access Log format
func Attribute ¶
func Attribute(option Option) restful.FilterFunction
Attribute filter is used to define the log attribute for the endpoint.
func MaskFields ¶
MaskFields will mask the field value on the content string based on the provided field name(s) in "fields" parameter separated by comma.
func MaskQueryParams ¶
MaskQueryParams will mask the field value on the uri based on the provided field name(s) in "fields" parameter separated by comma.
Types ¶
type FieldRegex ¶
type FieldRegex struct { FieldName string JsonPattern *regexp.Regexp QueryStringPattern *regexp.Regexp }
FieldRegex contains regex patterns for field name in varied content-types.
func (*FieldRegex) InitFieldRegex ¶
func (f *FieldRegex) InitFieldRegex(fieldName string)
InitFieldRegex initialize the FieldRegex along with its regex patterns.
type Option ¶
type Option struct { // Query param that need to masked in url, separated with comma MaskedQueryParams string // Field that need to masked in request body, separated with comma MaskedRequestFields string // Field that need to masked in response body, separated with comma MaskedResponseFields string }
Option contains attribute options for log functionality
type ResponseWriterInterceptor ¶ added in v4.10.0
type ResponseWriterInterceptor struct { http.ResponseWriter // contains filtered or unexported fields }
ResponseWriterInterceptor is used to decorate http.ResponseWriter, so we can intercept the Write process