Skip to content

Commit

Permalink
feat: better naming for system options
Browse files Browse the repository at this point in the history
  • Loading branch information
tigerwill90 committed Nov 28, 2024
1 parent 0765bb0 commit 2836f84
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ f = fox.New(
// A common use for this is if a server is both directly connected to the
// internet and expecting a header to check.
clientip.NewChain(
clientip.NewLeftmostNonPrivate(clientip.ForwardedKey),
clientip.NewLeftmostNonPrivate(clientip.ForwardedKey, 10),
clientip.NewRemoteAddr(),
),
),
Expand Down
4 changes: 2 additions & 2 deletions fox_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3971,7 +3971,7 @@ func TestParseRoute(t *testing.T) {

func TestParseRouteParamsConstraint(t *testing.T) {
t.Run("param limit", func(t *testing.T) {
f := New(WithMaxParams(3))
f := New(WithMaxRouteParams(3))
_, _, err := f.parseRoute("/{1}/{2}/{3}")
assert.NoError(t, err)
_, _, err = f.parseRoute("/{1}/{2}/{3}/{4}")
Expand All @@ -3980,7 +3980,7 @@ func TestParseRouteParamsConstraint(t *testing.T) {
assert.Error(t, err)
})
t.Run("param key limit", func(t *testing.T) {
f := New(WithMaxParamKeyBytes(3))
f := New(WithMaxRouteParamKeyBytes(3))
_, _, err := f.parseRoute("/{abc}/{abc}/{abc}")
assert.NoError(t, err)
_, _, err = f.parseRoute("/{abcd}/{abc}/{abc}")
Expand Down
8 changes: 4 additions & 4 deletions options.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,16 +81,16 @@ func WithOptionsHandler(handler HandlerFunc) GlobalOption {
})
}

// WithMaxParams set the maximum number of parameters allowed in a route. The default max is math.MaxUint16.
func WithMaxParams(max uint16) GlobalOption {
// WithMaxRouteParams set the maximum number of parameters allowed in a route. The default max is math.MaxUint16.
func WithMaxRouteParams(max uint16) GlobalOption {
return globOptionFunc(func(router *Router) {
router.maxParams = max
})
}

// WithMaxParamKeyBytes set the maximum number of bytes allowed per parameter key in a route. The default max is
// WithMaxRouteParamKeyBytes set the maximum number of bytes allowed per parameter key in a route. The default max is
// math.MaxUint16.
func WithMaxParamKeyBytes(max uint16) GlobalOption {
func WithMaxRouteParamKeyBytes(max uint16) GlobalOption {
return globOptionFunc(func(router *Router) {
router.maxParamKeyBytes = max
})
Expand Down

0 comments on commit 2836f84

Please sign in to comment.