Class: ShafClient
- Inherits:
-
Object
- Object
- ShafClient
- Extended by:
- Middleware::Cache::Control
- Defined in:
- lib/shaf_client/middleware/cache.rb,
lib/shaf_client.rb,
lib/shaf_client/form.rb,
lib/shaf_client/link.rb,
lib/shaf_client/curie.rb,
lib/shaf_client/resource.rb,
lib/shaf_client/base_resource.rb,
lib/shaf_client/middleware/redirect.rb
Overview
FIXME zip payload
Defined Under Namespace
Modules: Middleware Classes: BaseResource, Curie, Form, Link, Resource
Constant Summary collapse
- MIME_TYPE_JSON =
'application/json'
Instance Method Summary collapse
- #get_doc(uri, **options) ⇒ Object
- #get_form(uri, **options) ⇒ Object
- #get_root(**options) ⇒ Object
-
#initialize(root_uri, **options) ⇒ ShafClient
constructor
A new instance of ShafClient.
Methods included from Middleware::Cache::Control
cache_size, clear_cache, clear_stale_cache
Constructor Details
#initialize(root_uri, **options) ⇒ ShafClient
Returns a new instance of ShafClient.
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/shaf_client.rb', line 15 def initialize(root_uri, **) @root_uri = root_uri.dup adapter = .fetch(:faraday_adapter, :net_http) setup @client = Faraday.new(url: root_uri) do |conn| conn.basic_auth(@user, @pass) if basic_auth? conn.use Middleware::Cache, auth_header: auth_header conn.use Middleware::Redirect conn.adapter adapter end end |
Instance Method Details
#get_doc(uri, **options) ⇒ Object
37 38 39 40 |
# File 'lib/shaf_client.rb', line 37 def get_doc(uri, **) response = request(method: :get, uri: uri, opts: ) response&.body || '' end |
#get_form(uri, **options) ⇒ Object
32 33 34 35 |
# File 'lib/shaf_client.rb', line 32 def get_form(uri, **) response = request(method: :get, uri: uri, opts: ) Form.new(self, response.body, response.status, response.headers) end |
#get_root(**options) ⇒ Object
28 29 30 |
# File 'lib/shaf_client.rb', line 28 def get_root(**) get(@root_uri, **) end |