mirror of
https://github.com/HoneyryderChuck/httpx.git
synced 2025-08-10 00:01:27 -04:00
added plugin to top-level chainable; added plural version, to load multiple plugins
This commit is contained in:
parent
eccea7c443
commit
88b2c9370c
@ -58,6 +58,11 @@ module HTTPX
|
||||
headers("accept" => String(type))
|
||||
end
|
||||
|
||||
def plugin(*plugins)
|
||||
Class.new(Client).plugins(plugins).new(default_options)
|
||||
end
|
||||
alias :plugins :plugin
|
||||
|
||||
private
|
||||
|
||||
def default_options
|
||||
|
@ -105,7 +105,14 @@ module HTTPX
|
||||
default_options.response_body_class.extend(pl::ResponseBodyClassMethods) if defined?(pl::ResponseBodyClassMethods)
|
||||
pl.configure(self, *args, &block) if pl.respond_to?(:configure)
|
||||
end
|
||||
nil
|
||||
self
|
||||
end
|
||||
|
||||
def plugins(pls)
|
||||
pls.each do |pl, *args|
|
||||
plugin(pl, *args)
|
||||
end
|
||||
self
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user