Part of my application will be available as an API , so some of my pages should be available in JSON or XML (based on the Accept header of the Type header).
I used FOSRestBundle and it works very well, but now ALL of my pages are available in XML (or JSON) when sending the Accept 'Content Type: Application / XML header.
So, I would like to enable / disable this feature for some of my controllers / actions. I would ideally do this using annotations.
Is it possible?
My config.yml:
fos_rest:
view:
formats:
rss: false
xml: true
json: true
templating_formats:
html: true
force_redirects:
html: false
failed_validation: HTTP_BAD_REQUEST
default_engine: twig
view_response_listener: force
body_listener:
decoders:
json: acme.decoder.json
xml: fos_rest.decoder.xml
format_listener:
default_priorities: ['html', 'xml', 'json', '*/*']
fallback_format: html
prefer_extension: false
source
share