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

Can't use my own model with content negotiation #5

Open
weierophinney opened this issue Dec 31, 2019 · 1 comment
Open

Can't use my own model with content negotiation #5

weierophinney opened this issue Dec 31, 2019 · 1 comment

Comments

@weierophinney
Copy link
Contributor

Hi!

I got an API with content negotiation. For binaries resources, the caller don't know the mime type.
Typically, if it's a element in an HTML page, I can't specify headers.

When the resource GET method is called, the server knows its type, and I can return an ImageModel or PdfModel or whatever I need instead of HalEntity or HalCollection, but the RestController encapsulate my model into a new entity and a ContentNegotiationViewModel... :-/

Rest controller should bypass contentNegotiation if I want to use my own model.


Originally posted by @webaaz at zfcampus/zf-rest#89

@weierophinney
Copy link
Contributor Author

I use a patch to bypass, setting headers in the resource

$this->getEvent()->getRequest()->getHeaders()->addHeaderLine('content-type', 'application/pdf');

I think it's not the best way...


Originally posted by @webaaz at zfcampus/zf-rest#89 (comment)

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

No branches or pull requests

1 participant