docs: testing of media handlers as a note

Otherwise users think they're required steps. See the opening comment on
https://github.com/PostgREST/postgrest/issues/3124.
This commit is contained in:
steve-chavez
2024-01-02 23:44:53 -05:00
committed by Steve Chavez
parent f73845159c
commit 50ac91d1ae
+11 -5
View File
@@ -95,7 +95,9 @@ Now we'll use it on a new aggregate defined for the ``lines`` table.
, sfunc = twkb_handler_transition , sfunc = twkb_handler_transition
); );
Make a quick test on SQL to see it working. .. note::
You can test see this aggregate working with:
.. code-block:: psql .. code-block:: psql
@@ -184,6 +186,10 @@ Now use the transition and final function as part of the new aggregate.
, finalfunc = bom_csv_final , finalfunc = bom_csv_final
); );
.. note::
You can test this with:
.. code-block:: psql .. code-block:: psql
select bom_csv_agg(l) from lines l; select bom_csv_agg(l) from lines l;
@@ -215,11 +221,11 @@ And request it like:
The "Any" Handler The "Any" Handler
================= =================
For more flexibility, you can also define a catch-all handler by using a domain named ``*/*`` (any media type). This obeys to the following rules: For more flexibility, you can also define a catch-all handler by using a domain named ``*/*`` (any media type). This handler obeys the following rules:
- Responds to all media types and even to requests that don't include an ``Accept`` header. - It responds to all media types and even to requests that don't include an ``Accept`` header.
- Sets the ``Content-Type`` header to ``application/octet-stream`` by default, but this can be overridden inside the function with :ref:`guc_resp_hdrs`. - It sets the ``Content-Type`` header to ``application/octet-stream`` by default, but this can be overridden inside the function with :ref:`guc_resp_hdrs`.
- This overrides all other handlers (:ref:`builtin <builtin_media>` or custom), so it's better to do it for an isolated function or view. - It overrides all other handlers (:ref:`builtin <builtin_media>` or custom), so it's better to do it for an isolated function or view.
Let's define an any handler for a view that will always respond with ``XML`` output. It will accept ``text/xml``, ``application/xml``, ``*/*`` and reject other media types. Let's define an any handler for a view that will always respond with ``XML`` output. It will accept ``text/xml``, ``application/xml``, ``*/*`` and reject other media types.