mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Link rel=alternate header for tables and rows
Also added Access-Control-Expose-Headers: Link to --cors mode. Closes #1533 Refs https://github.com/simonw/datasette-notebook/issues/2 LL# metadata.json.1
This commit is contained in:
parent
2aa686c655
commit
3ef47a0896
9 changed files with 86 additions and 6 deletions
|
|
@ -14,6 +14,7 @@ served with the following additional HTTP headers::
|
|||
|
||||
Access-Control-Allow-Origin: *
|
||||
Access-Control-Allow-Headers: Authorization
|
||||
Access-Control-Expose-Headers: Link
|
||||
|
||||
This means JavaScript running on any domain will be able to make cross-origin
|
||||
requests to fetch the data.
|
||||
|
|
@ -435,3 +436,22 @@ looks like::
|
|||
|
||||
The column in the foreign key table that is used for the label can be specified
|
||||
in ``metadata.json`` - see :ref:`label_columns`.
|
||||
|
||||
.. _json_api_discover_alternate:
|
||||
|
||||
Discovering the JSON for a page
|
||||
-------------------------------
|
||||
|
||||
The :ref:`table <TableView>` and :ref:`row <RowView>` HTML pages both provide a mechanism for discovering their JSON equivalents using the HTML ``link`` mechanism.
|
||||
|
||||
You can find this near the top of those pages, looking like this:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
<link rel="alternate"
|
||||
type="application/json+datasette"
|
||||
href="https://latest.datasette.io/fixtures/sortable.json">
|
||||
|
||||
The JSON URL is also made available in a ``Link`` HTTP header for the page::
|
||||
|
||||
Link: https://latest.datasette.io/fixtures/sortable.json; rel="alternate"; type="application/json+datasette"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue