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

Creating adapters by media-types. #1062

Closed
bacarini opened this issue Aug 18, 2015 · 5 comments
Closed

Creating adapters by media-types. #1062

bacarini opened this issue Aug 18, 2015 · 5 comments

Comments

@bacarini
Copy link
Contributor

I would like to know what is yours thoughts about creating adapters by media-types.
Ex.

GET http://example.com/posts  
render with flatten-json adapter

GET http://example.com/posts  --headers "Content-type: application/vnd.api+json" 
render with json-api adapter

GET http://example.com/posts  --headers "Content-type: application/json" 
render with json adapter

GET http://example.com/posts  --headers "Content-type: application/hal+json" 
render with hal adapter (hypothetically)

GET http://example.com/posts  --headers "Content-type: application/vnd.collection+json" 
render with collection-json adapter (hypothetically)

@akaKuruma and I want to implement that if it is approved.

@joaomdmoura
Copy link
Member

I've implemented it on a fork of AMS already, with some hacks.
I'm not sure about it yet, for json-api it makes a lot of sense, but it seems the kind of decision you don't want to infer, once you even have the initializer to set it, or the possibility to lock it on one adapter using the adapte options on render.
Also not sure if it could bother something to ppl that use ActionController::Responder.

I'll keep this open for now, but we might need some ppl backing this up in order to make it happen 😄

@akaKuruma
Copy link

@joaomdmoura could you share your implementation?

@bacarini
Copy link
Contributor Author

@joaomdmoura, we were thinking about it but not has default. As long as user send it through render We will not override it.
ex.
If adapter options is defined on render, AMS will serialize the model even if the user sends headers with application/hal+json(hypothetically). But if it is not specify on render we may look at content-type.
At last, if there is netheir defined in render nor content-type, it could get from initializer configuration.

Does it make sense? Did I make myself clear? 😄

What do you think?

@beauby
Copy link
Contributor

beauby commented Aug 28, 2015

I'm interested to know about the use cases of this feature.

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

Successfully merging a pull request may close this issue.

5 participants