```ruby
module WeakHeaders
  module Controller
    def validates_headers(*args, &block)
      filter_options = {}
      filter_options.merge!(only: args.flatten) unless args.empty?

      before_filter filter_options do
        validator = WeakHeaders::Validator.new(self, &block)
        WeakHeaders.stats[params[:controller]][params[:action]] = validator
        WeakHeaders.stats[params[:controller]][params[:action]].validate
      end
    end
  end
end
```

Use before_action instead of before_filter DEPRECATION WARNING: before_filter is deprecated and will be removed in Rails 5.1
user
```ruby
module WeakHeaders
  module Controller
    def validates_headers(*args, &block)
      filter_options = {}
      filter_options.merge!(only: args.flatten) unless args.empty?

      before_action filter_options do
        validator = WeakHeaders::Validator.new(self, &block)
        WeakHeaders.stats[params[:controller]][params[:action]] = validator
        WeakHeaders.stats[params[:controller]][params[:action]].validate
      end
    end
  end
end
```
assistant