No activity today, make something!
tiddlyweb content negotiation

20160313160624 cdent  

Wikipedia says that content negotiation

is a mechanism defined in the HTTP specification that makes it possible to serve different versions of a document (or more generally, a resource) at the same URI, so that user agents can specify which version fit their capabilities the best.

TiddlyWeb uses content negotiation to allow a user agent to declare which representation of a resource it prefers. Using the {{{Accept}}} header the user agent can declare that it wants a {{{text/plain}}}, {{{text/html}}} or {{{application/vnd.tiddlyweb+json}}} ( or even {{{application/json}}}) version of a resource (if available). With plugins other representations can be made available.

Content negotiation is a very significant contributor making any HTTP API powerful and flexible.

A user agent (often a person using a web browser) may also adjust the request URL to add an extension to simulate setting the {{{Accept}}} header. For example to get the plain text representation of a bag resource one might request:

{{{ GET /bags/mybag.txt }}}

The default available extensions are:

  • html to get {{{text/html}}}
  • txt to get {{{text/plain}}}
  • json to get {{{application/vnd.tiddlyweb+json}}}

TiddlyWebWiki adds:

  • wiki to get {{{text/x-tiddlywiki}}}

Not all resources provide all representations. See the HTTP API for details.

Supported extensions can be extended by creating and configuring another serialization in a plugin.