Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
e398993
First create some structure to fill in the content in next commits
christianlupus Jan 29, 2025
2f1bc35
Move section html templates
christianlupus Feb 28, 2025
9e95840
Moved section public html templates
christianlupus Feb 28, 2025
af0cad8
Move section OCS
christianlupus Feb 28, 2025
578cbce
Move section JSON
christianlupus Feb 28, 2025
e58d1ff
Move section Responders
christianlupus Feb 28, 2025
1693e6e
Moving section handling errors
christianlupus Feb 28, 2025
24e4e6b
Moving section Authentication
christianlupus Feb 28, 2025
30c5183
Move section Content security policy
christianlupus Feb 28, 2025
c2040e8
Moving section Redirects
christianlupus Feb 28, 2025
0ac03ca
Move section Downloads
christianlupus Feb 28, 2025
ef9fb32
Move section custom responses
christianlupus Feb 28, 2025
ef54c9e
Move section Streamed/lazily rendered Content
christianlupus Feb 28, 2025
7d41100
Move section Rate Limiting
christianlupus Feb 28, 2025
27c0ce5
Move section brute-force protection
christianlupus Feb 28, 2025
0935fa8
Adding some introductions to new chapter structure
christianlupus Feb 28, 2025
bc321ab
Update some texts to reflect current situation better
christianlupus Feb 28, 2025
9388034
Make CSRF check clearer
christianlupus Feb 28, 2025
d3348cd
Add more examples in the Authentication section
christianlupus Feb 28, 2025
e2b2504
Fix some minor punctuation
christianlupus Feb 28, 2025
17043e2
Update routing file
christianlupus Feb 28, 2025
5435dcd
Apply suggestions from code review
christianlupus Feb 28, 2025
b8b0411
Apply suggestions from code review
christianlupus Feb 28, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions developer_manual/basics/controllers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -452,8 +452,8 @@ OCS
.. note::
This is purely for compatibility reasons. If you are planning to offer an external API, go for a :ref:`REST APIs <rest-apis>` instead.

In order to ease migration from OCS API routes to the App Framework, an additional controller and response have been added.
To migrate your API you can use the **OCP\\AppFramework\\OCSController** base class and return your data in the form of a DataResponse in the following way:
In order to simplify exchange of data between the Nextcloud backend and any client (be it the web frontend or whatever else), the OCS API has been introduced.
To use OCS in your API you can use the **OCP\\AppFramework\\OCSController** base class and return your data in the form of a **DataResponse** in the following way:

.. code-block:: php

Expand All @@ -475,9 +475,14 @@ To migrate your API you can use the **OCP\\AppFramework\\OCSController** base cl

}

The format parameter works out of the box, no intervention is required.
For ``OCSController`` classes and their methods, :ref:`responders <controller-responders>` can be registered as with any other ``Controller`` method.
The ``OCSController`` class have however automatically two responders 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=`` query 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 of your app. Inside these are normal routes.
In order to make routing work for OCS routes you need to add :ref:`a separate 'ocs' entry<routes_ocs>` to the routing table in ``appinfo/routes.php`` of your app.
Inside these, there are the same information as there are for normal routes.

.. code-block:: php

Expand All @@ -495,6 +500,10 @@ In order to make routing work for OCS routes you need to add a separate ‘ocs

Now your method will be reachable via ``<server>/ocs/v2.php/apps/<APPNAME>/api/v1/shares``

.. versionadded:: 29
You can use the attribute ``ApiRoute`` as described in :doc:`Routing <routing>` instead of the entry in ``appinfo/routes.php`` as an alternative.


JSON
^^^^

Expand Down