Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dealing With Other Media Types #42

Open
benhamill opened this issue Oct 15, 2013 · 3 comments
Open

Dealing With Other Media Types #42

benhamill opened this issue Oct 15, 2013 · 3 comments

Comments

@benhamill
Copy link
Contributor

Imagine I get some HAL from a server that looks like this (in part, maybe):

{
  '_links': {
    'self': { 'href': '/users/12345' },
    'profile_image': { 'href': '/user/12345/face' }
  }
}

And I am super interested in profile images, so I want to get that sucker. Right now, if I call, you know, user.links.profile_image.resource I get back a sort of confused Hyperclient::Resource that can't tell me the media type is jpeg or whatever. I could call get instead of resource, but then I have to know more about the foreign API.

I wonder if we shouldn't make it so that Hyperclient, when it sees a response from a server that isn't Content-Type: application/hal+json (or maybe a list to include normal application/json and that a user could add to), it just hands over the Faraday::Response object or something similar. Basically, it punts and says, "This isn't hypermedia I know about, you handle this bullshit."

Thoughts?

@benhamill
Copy link
Contributor Author

Oh. One more thing: This sort of ties into #41 in that, if Link#resource isn't a thing, and everyone always used the methods named after HTTP verbs, then those methods would be the point where we'd do the intelligent thing.

@dblock
Copy link
Collaborator

dblock commented Sep 30, 2014

+1, I think that it would be very helpful to differentiate the media types when following hyperlinks. Definitely return some base type that's not JSON to start.

@dblock
Copy link
Collaborator

dblock commented Oct 16, 2014

In #73 I made a change that returned Resource objects from all these methods. We could just examine the content type of the response before assigning these and return something else.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants