Documentation ¶
Index ¶
- Variables
- func DefaultValueSanitizer(_ string, _ ...string) []string
- func Request(r *http.Request, opts ...RequestOption) *http.Request
- type RequestOption
- func OptRequestAddDisallowedHeaders(headers ...string) RequestOption
- func OptRequestAddDisallowedQueryParams(queryParams ...string) RequestOption
- func OptRequestSetDisallowedHeaders(headers ...string) RequestOption
- func OptRequestSetDisallowedQueryParams(queryParams ...string) RequestOption
- func OptRequestValueSanitizer(valueSanitizer ValueSanitizer) RequestOption
- type RequestOptions
- type ValueSanitizer
Constants ¶
This section is empty.
Variables ¶
var ( DefaultSanitizationDisallowedHeaders = []string{"authorization", "cookie", "set-cookie"} DefaultSanitizationDisallowedQueryParams = []string{"access_token", "client_secret"} )
Default values for disallowed field names Note: the values are compared using `strings.EqualFold` so the casing shouldn't matter
Functions ¶
func DefaultValueSanitizer ¶
DefaultValueSanitizer is the default value sanitizer.
Types ¶
type RequestOption ¶
type RequestOption func(*RequestOptions)
RequestOption is a function that mutates sanitization options.
func OptRequestAddDisallowedHeaders ¶
func OptRequestAddDisallowedHeaders(headers ...string) RequestOption
OptRequestAddDisallowedHeaders adds disallowed headers, augmenting defaults.
func OptRequestAddDisallowedQueryParams ¶
func OptRequestAddDisallowedQueryParams(queryParams ...string) RequestOption
OptRequestAddDisallowedQueryParams adds disallowed query params, augmenting defaults.
func OptRequestSetDisallowedHeaders ¶
func OptRequestSetDisallowedHeaders(headers ...string) RequestOption
OptRequestSetDisallowedHeaders sets the disallowed headers, overwriting defaults.
func OptRequestSetDisallowedQueryParams ¶
func OptRequestSetDisallowedQueryParams(queryParams ...string) RequestOption
OptRequestSetDisallowedQueryParams sets the disallowed query params, overwriting defaults.
func OptRequestValueSanitizer ¶
func OptRequestValueSanitizer(valueSanitizer ValueSanitizer) RequestOption
OptRequestValueSanitizer sets the value sanitizer.
type RequestOptions ¶
type RequestOptions struct { DisallowedHeaders []string DisallowedQueryParams []string ValueSanitizer ValueSanitizer }
RequestOptions are options for sanitization of http requests.
func (RequestOptions) IsHeaderDisallowed ¶
func (ro RequestOptions) IsHeaderDisallowed(header string) bool
IsHeaderDisallowed returns if a header is in the disallowed list.
func (RequestOptions) IsQueryParamDisallowed ¶
func (ro RequestOptions) IsQueryParamDisallowed(queryParam string) bool
IsQueryParamDisallowed returns if a query param is in the disallowed list.
type ValueSanitizer ¶
ValueSanitizer is a function that sanitizes values.
It's designed to accept a variadic list of values that represent the Value of maps like `http.Header` and `url.Values`