how to turn off the rendering of html responses in twig?
I'm building a RESTful API and want to completly disable HTML rendering. For example if I request /foo/bar without an oAuth Access Token, symfony2 should responses with a 401 json message instead of a 401 html template.
Greetings
Just don't call the render method : return $this->render('FooBarBundle:Default:index.html.twig');
Instead of this, you can call in your controller :
return new JsonResponse(array(
'message' => 'Your message here'
), 401);