-
Notifications
You must be signed in to change notification settings - Fork 0
Lesson 3A: Serve your data in many different flavors
So many developers and devices, so many flavors. Serve your data in as many flavors as possible to reach the widest possible audience.
The scope of projects often limits the number of supported data formats as much as possible to 1. If that's the case, you should temper your expectations of adoption and make sure you leave room for future formats right from the beginning. This can be achieved by defining a good content-negotiation strategy.
Flexibility to switch between different data flavors to serve the large set of unknown developers and devices.
Define a content-negotation strategy.
More practically, use
-
Accept-headers:
The Accept header tells the server what file formats, or more correctly MIME-types, the browser is looking for. For example an request for a (Geo)JSON data object:GET /data/object
Accept: application/json
and response:HTTP/1.1 201 Created
Content-Type: application/json
-
URL based content-negotation:
Some clients insist to request specific media types using parameters in an URL.
For example,
http://definities.geostandaarden.nl/concepten/imgeo/doc/begrip/Bak
directs to an normal HTML-page while
http://definities.geostandaarden.nl/concepten/imgeo/doc/begrip/Bak?format=json
will return JSON.
The second second phase of the testbed confirmed that the use of URL-based content negotiation should be discouraged.