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

Doing a request without accept header causes an exception #88

Open
macnibblet opened this issue Jul 23, 2013 · 4 comments
Open

Doing a request without accept header causes an exception #88

macnibblet opened this issue Jul 23, 2013 · 4 comments

Comments

@macnibblet
Copy link
Contributor

I had this strange error with my application just now until i figured out that i was not setting the Accept header.

Exposed message was Zend\View\Renderer\PhpRenderer::render: Unable to render template "phly-restfully/resource/get"; resolver could not resolve to a file

@weierophinney
Copy link
Contributor

Basically, we have the ability to set Accept criteria via the "accept_criteria" configuration key of each controller. However, this always defaults to the default ViewModel implementation -- which means the default renderer implementation, the PhpRenderer, will be selected.

So, you have a couple of options currently:

  • Add accept criteria for "text/html" (etc.) that returns a RestfulJsonModel. This will mean all requests return JSON; it may not be semantically correct, in other words.
  • Add a listener on the resource controller's dispatch event to either pre-check for an appropriate Accept header and short circuite, or post-check for a RestfulJsonModel and short-circuit (both returning a 406 status).

The question I have is: should this be a feature of the module? In other words should I have a listener by default, and allow opting-in to it by selected resource controller?

@weierophinney
Copy link
Contributor

@macnibblet Any comments on the above?

@macnibblet
Copy link
Contributor Author

I like the second idea of using a listener and short circuiting with an ApiProblem with appropriate information and a http status code of 406.

Is there any good use case for using a post-check ?

@macnibblet
Copy link
Contributor Author

Another interesting issue i found is that angularjs default Content-Type header is application/xml which caused some really weird and unexpected behavior and also should be resolved.

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

2 participants