-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
There are cases where I want to use keys other than the fixed ones. #5
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
We need to choose host or remote_addr, right?
base_limiter.go
Outdated
@@ -58,3 +59,19 @@ func (l *BaseLimiter) isTargetExtensions(r *http.Request) bool { | |||
} | |||
return false | |||
} | |||
func validateKey(key string) error { | |||
for _, k := range []string{"remote_addr", "host"} { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"remote_addr" and "host" may be const variables.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see.
I should to make constaiant variable host and remote_addr.
I will do afer cristmas..
Yes!!! |
Co-authored-by: Ken’ichiro Oyama <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thank you!!!
I've made adjustments because there are cases where I want to block not just based on the host, but also on IP for limiters of GET parameters and request paths.