3 ms·
Here's a simple use case: human friendly and machine friendly representations at the same path. For example, let's say I have an api at `/weather` which when r
by mstade 3y ago
Here's a simple use case: human friendly and machine friendly representations at the same path.
For example, let's say I have an api at `/weather` which when requested with the header `accept: application/json` returns something like:
{ "temperature": 25, "unit": "c" }
Now if I open that same path in a browser, I get an html page displaying the day's temperature in a nicely formatted way for humans to read.
Or another case, I want to version an API, such that I can provide different representations based on the version requested. So I look for `accept-version` and if it's `v1` for example I get the `v1` version. GitHub does this, as a real world example: https://docs.github.com/en/rest/overview/api-versions?apiVersion=2022-11-28 https://docs.github.com/en/rest/overview/api-versions?apiVer...
- keithwhor 3y agoEntirely possible! I mean right now we restrict endpoint definitions to HTTP methods but in theory you could define unique endpoints for any combination of parameters. What I would want to find is the most effective / used combinations as opposed to unlimited flexibility.