Class: TentD::API::Followings::Discover
- Inherits:
-
Middleware
- Object
- Middleware
- TentD::API::Followings::Discover
- Defined in:
- lib/tentd/api/followings.rb
Instance Method Summary collapse
Methods inherited from Middleware
Methods included from Authorizable
#authorize_env!, #authorize_env?
Constructor Details
This class inherits a constructor from TentD::API::Middleware
Instance Method Details
#action(env) ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/tentd/api/followings.rb', line 67 def action(env) client = ::TentClient.new(nil, :faraday_adapter => TentD.faraday_adapter) profile, profile_url = client.discover(env.params.data.entity).get_profile return [404, {}, ['Not Found']] unless profile profile = CoreProfileData.new(profile) return [409, {}, ['Entity Mismatch']] unless profile.entity?(env.params.data.entity) env.profile = profile env.server_url = profile_url.sub(%r{/profile$}, '') env end |