Files
main.tsmain
What you'll learn
- Tell a resource from its representations, and pick one from the Accept header, weighing q-values
- Refuse with 406 when nothing acceptable can be produced and 415 when a request body cannot be read
- Say Vary: Accept on a negotiated answer, so a cache does not hand one client's format to another
Press Run tests to start the app. Its log appears here.Graded endpoints
A client that states no preference gets the default, JSON
The same resource in another representation: a header line, then one line per cat
CSV is acceptable but JSON is preferred: q=0.5 ranks below the default of 1
XML comes first and is not available; CSV, even at q=0.1, is
*/* accepts every type, so the server picks its default
406 Not Acceptable: the client accepts nothing the server can produce, and the answer says what it can
415 Unsupported Media Type: the server cannot read a form, and does not try
The bytes happen to be JSON, but the label says text/plain, and the label is what a server goes by
A parameter after the type does not change it: this is JSON
Both representations show the same state
The item route, unchanged
404, unchanged