From ca6794c995f8b00cdd6fff9ab29d4f5f13ce9e89 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..65bdc782f54 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 respo nders 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 advised 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.