Skip to content

Commit

Permalink
to migrate const
Browse files Browse the repository at this point in the history
  • Loading branch information
pyama86 committed Dec 23, 2023
1 parent c26a875 commit 77df7c7
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 19 deletions.
7 changes: 6 additions & 1 deletion base_limiter.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ import (
"github.com/2manymws/rl/counter"
)

const (
remoteAddrKey = "remote_addr"
hostKey = "host"
)

type BaseLimiter struct {
reqLimit int `mapstructure:"req_limit"`
windowLen time.Duration
Expand Down Expand Up @@ -60,7 +65,7 @@ func (l *BaseLimiter) isTargetExtensions(r *http.Request) bool {
return false
}
func validateKey(key string) error {
for _, k := range []string{"remote_addr", "host"} {
for _, k := range []string{remoteAddrKey, hostKey} {
if k == key {
return nil
}
Expand Down
36 changes: 18 additions & 18 deletions coverage.out
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
mode: count
github.com/2manymws/rlutils/base_limiter.go:27.15,36.2 2 22
github.com/2manymws/rlutils/base_limiter.go:38.70,40.2 1 0
github.com/2manymws/rlutils/base_limiter.go:42.37,44.2 1 0
github.com/2manymws/rlutils/base_limiter.go:46.61,48.2 1 23
github.com/2manymws/rlutils/base_limiter.go:50.64,51.34 1 29
github.com/2manymws/rlutils/base_limiter.go:51.34,53.3 1 24
github.com/2manymws/rlutils/base_limiter.go:54.2,55.41 2 5
github.com/2manymws/rlutils/base_limiter.go:55.41,56.40 1 8
github.com/2manymws/rlutils/base_limiter.go:56.40,58.4 1 3
github.com/2manymws/rlutils/base_limiter.go:60.2,60.14 1 2
github.com/2manymws/rlutils/base_limiter.go:62.36,63.52 1 12
github.com/2manymws/rlutils/base_limiter.go:63.52,64.15 1 22
github.com/2manymws/rlutils/base_limiter.go:64.15,66.4 1 12
github.com/2manymws/rlutils/base_limiter.go:68.2,68.43 1 0
github.com/2manymws/rlutils/base_limiter.go:71.50,72.26 1 7
github.com/2manymws/rlutils/base_limiter.go:72.26,75.3 2 2
github.com/2manymws/rlutils/base_limiter.go:76.2,76.15 1 5
github.com/2manymws/rlutils/base_limiter.go:32.15,41.2 2 22
github.com/2manymws/rlutils/base_limiter.go:43.70,45.2 1 0
github.com/2manymws/rlutils/base_limiter.go:47.37,49.2 1 0
github.com/2manymws/rlutils/base_limiter.go:51.61,53.2 1 23
github.com/2manymws/rlutils/base_limiter.go:55.64,56.34 1 29
github.com/2manymws/rlutils/base_limiter.go:56.34,58.3 1 24
github.com/2manymws/rlutils/base_limiter.go:59.2,60.41 2 5
github.com/2manymws/rlutils/base_limiter.go:60.41,61.40 1 8
github.com/2manymws/rlutils/base_limiter.go:61.40,63.4 1 3
github.com/2manymws/rlutils/base_limiter.go:65.2,65.14 1 2
github.com/2manymws/rlutils/base_limiter.go:67.36,68.53 1 12
github.com/2manymws/rlutils/base_limiter.go:68.53,69.15 1 22
github.com/2manymws/rlutils/base_limiter.go:69.15,71.4 1 12
github.com/2manymws/rlutils/base_limiter.go:73.2,73.43 1 0
github.com/2manymws/rlutils/base_limiter.go:76.50,77.26 1 7
github.com/2manymws/rlutils/base_limiter.go:77.26,80.3 2 2
github.com/2manymws/rlutils/base_limiter.go:81.2,81.15 1 5
github.com/2manymws/rlutils/country_limiter.go:36.28,38.16 2 6
github.com/2manymws/rlutils/country_limiter.go:38.16,40.3 1 0
github.com/2manymws/rlutils/country_limiter.go:41.2,44.30 3 6
Expand Down Expand Up @@ -53,7 +53,7 @@ github.com/2manymws/rlutils/get_parameter_limiter.go:42.45,44.2 1 0
github.com/2manymws/rlutils/get_parameter_limiter.go:46.71,47.27 1 4
github.com/2manymws/rlutils/get_parameter_limiter.go:47.27,49.3 1 0
github.com/2manymws/rlutils/get_parameter_limiter.go:50.2,50.36 1 4
github.com/2manymws/rlutils/get_parameter_limiter.go:50.36,51.32 1 4
github.com/2manymws/rlutils/get_parameter_limiter.go:50.36,51.32 1 5
github.com/2manymws/rlutils/get_parameter_limiter.go:51.32,57.4 1 3
github.com/2manymws/rlutils/get_parameter_limiter.go:60.2,60.36 1 1
github.com/2manymws/rlutils/get_parameter_limiter.go:63.78,65.2 1 0
Expand Down

0 comments on commit 77df7c7

Please sign in to comment.