Skip to content

Commit

Permalink
Merge pull request #6020 from avalonmediasystem/mo_index_groups
Browse files Browse the repository at this point in the history
Override RSolr::Client to fallback to ActiveFedora#default_http_method
  • Loading branch information
masaball authored Sep 4, 2024
2 parents 43b075f + 61eb742 commit 2011b2a
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions config/initializers/rsolr.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
RSolr::Client.class_eval do
def build_request path, opts
raise "path must be a string or symbol, not #{path.inspect}" unless [String,Symbol].include?(path.class)
path = path.to_s
opts[:proxy] = proxy unless proxy.nil?
# Avalon can produce requests that are too large for :get.
# Override method to use configurable http method to avoid
# having to override every instance that calls RSolr directly.
opts[:method] ||= ActiveFedora::SolrService.default_http_method
raise "The :data option can only be used if :method => :post" if opts[:method] != :post and opts[:data]
opts[:params] = params_with_wt(opts[:params])
query = RSolr::Uri.params_to_solr(opts[:params]) unless opts[:params].empty?
opts[:query] = query
if opts[:data].is_a? Hash
opts[:data] = RSolr::Uri.params_to_solr opts[:data]
opts[:headers] ||= {}
opts[:headers]['Content-Type'] ||= 'application/x-www-form-urlencoded; charset=UTF-8'
end
opts[:path] = path
opts[:uri] = base_uri.merge(path.to_s + (query ? "?#{query}" : "")) if base_uri

opts
end
end

0 comments on commit 2011b2a

Please sign in to comment.