Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Link: rel="alternate" to JSON for queries too #1620

Closed
simonw opened this issue Feb 2, 2022 · 3 comments
Closed

Link: rel="alternate" to JSON for queries too #1620

simonw opened this issue Feb 2, 2022 · 3 comments

Comments

@simonw
Copy link
Owner

simonw commented Feb 2, 2022

Following:

I implemented it for tables and rows but I should have done queries as well.

@simonw
Copy link
Owner Author

simonw commented Feb 2, 2022

I just realized I can refactor this to make it much simpler.

@simonw
Copy link
Owner Author

simonw commented Feb 2, 2022

% curl -s -I 'https://latest.datasette.io/' | grep link
link: https://latest.datasette.io/.json; rel="alternate"; type="application/json+datasette"
% curl -s -I 'https://latest.datasette.io/fixtures' | grep link
link: https://latest.datasette.io/fixtures.json; rel="alternate"; type="application/json+datasette"
% curl -s -I 'https://latest.datasette.io/fixtures?sql=select+1' | grep link
link: https://latest.datasette.io/fixtures.json?sql=select+1; rel="alternate"; type="application/json+datasette"
% curl -s -I 'https://latest.datasette.io/-/plugins' | grep link 
link: https://latest.datasette.io/-/plugins.json; rel="alternate"; type="application/json+datasette"

@simonw
Copy link
Owner Author

simonw commented Feb 2, 2022

I ran the following on https://www.google.com/ in the console to demonstrate that these work as intended:

[
  "https://latest.datasette.io/fixtures",
  "https://latest.datasette.io/fixtures?sql=select+1",
  "https://latest.datasette.io/fixtures/facetable"
].forEach(async (url) => {
  response = await fetch(url, {method: "HEAD"});
  console.log(response.headers.get("Link"));
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant