You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
require 'my_client/paginator'
require 'rest_in_peace'
require 'faraday'
module MyClient
class Fabric
include RESTinPeace
rest_in_peace do
use_api ->() do
::Faraday.new(url: 'http://localhost:3001', headers: { 'Accept' => 'application/json' }) do |faraday|
faraday.request :json
faraday.response :json
faraday.adapter :excon
faraday.headers['Accept-Version'] = 'v1'
end
end
attributes do
read :id
write :name
end
resource do
patch :save, '/fabrics/:id'
post :create, '/fabrics'
delete :destroy, '/fabrics/:id'
get :reload, '/fabrics/:id'
end
collection do
get :all, '/fabrics', paginate_with: MyClient::Paginator
get :find, '/fabrics/:id'
end
acts_as_active_model
end
end
end
We are setting static version in the headers in this example. We can access the client in this way:
MyClient::Fabric.find(id: 1)
But is there any way to set the headers['Accept-Version'] dynamically? So for example for find method I will use version v1 and for all method I will use version v2.
Is it possible via REST-in-Peace gem?
Thank You!
The text was updated successfully, but these errors were encountered:
Hello,
For this example:
We are setting static version in the
headers
in this example. We can access the client in this way:But is there any way to set the
headers['Accept-Version']
dynamically? So for example forfind
method I will use versionv1
and forall
method I will use versionv2
.Is it possible via
REST-in-Peace
gem?Thank You!
The text was updated successfully, but these errors were encountered: