Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type RequestBlocker ¶
type RequestBlocker struct {
// contains filtered or unexported fields
}
RequestBlocker blocks request according to rules that defines which headers are not allowed
func NewRequestBlocker ¶
func NewRequestBlocker(blockHeaderFile string, updatePeriod time.Duration, logger *zap.Logger) *RequestBlocker
NewRequestBlocker creates a new instance of request blocker without any rules and sets name of config files that will be used as storage for rules
func (*RequestBlocker) AddNewRules ¶
func (rl *RequestBlocker) AddNewRules(queryParams url.Values) bool
AddNewRules updates rule config file with new rules
func (*RequestBlocker) ReloadRules ¶
func (rl *RequestBlocker) ReloadRules()
ReloadRules loads rules from config and updates blocker with these rules
func (*RequestBlocker) ScheduleRuleReload ¶
func (rl *RequestBlocker) ScheduleRuleReload() bool
ScheduleRuleReload starts reload rules from rules config file with frequency defined by updatePeriod
func (*RequestBlocker) ShouldBlockRequest ¶
func (rl *RequestBlocker) ShouldBlockRequest(r *http.Request) bool
ShouldBlockRequest checks request headers against block rules
func (*RequestBlocker) Unblock ¶
func (rl *RequestBlocker) Unblock() error
Unblock deletes rule config file with all defined rules. Next time rules will be reloaded, request blocker won't block any request
type RuleConfig ¶
type RuleConfig struct {
Rules []Rule
}
RuleConfig represents the request blocking rules