From 08e4aab83013bc91c5e45446a90302b4d997c1fd Mon Sep 17 00:00:00 2001 From: Christian Wolf Date: Wed, 9 Oct 2024 00:30:22 +0200 Subject: [PATCH] Fix text about responders Signed-off-by: Christian Wolf --- developer_manual/basics/controllers.rst | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/developer_manual/basics/controllers.rst b/developer_manual/basics/controllers.rst index 587c0d9ab82..7ca94b3e425 100644 --- a/developer_manual/basics/controllers.rst +++ b/developer_manual/basics/controllers.rst @@ -382,6 +382,8 @@ Because returning JSON is such a common task, there's even a shorter way to do t Why does this work? Because the dispatcher sees that the controller did not return a subclass of a Response and asks the controller to turn the value into a Response. That's where responders come in. +.. _controller-responders: + Responders ^^^^^^^^^^ @@ -762,7 +764,11 @@ To use OCS in your API you can use the **OCP\\AppFramework\\OCSController** base } -The format parameter works out of the box, no intervention is required. +For ``OCSController`` classes and their methods, :ref:`responders ` can be registered as with any other ``Controller`` method. +The ``OCSController`` class have however automatically two respnders pre-installed: +Both JSON (``application/json``) and XML (``text/xml``) are generated on-the-fly depending on the request by the browser/user. +To select the output format, the format parameter or the ``Accept`` header of the request work out of the box, no intervention is required. +It is adviced to prefer the header generally, as this is the more programmatic way. In order to make routing work for OCS routes you need to add a separate 'ocs' entry to the routing table in ``appinf/routes.php`` of your app. Inside these are normal routes.