tomchristie/django-rest-framework — Issue #137: Modify HTML view to include request info.
Author: btimby
Created: 2012-01-19 20:40:33+00:00
State: open

I noticed the following in renderers.py:

context = RequestContext(self.view.request, {
'content': content,
'view': self.view,
'request': self.view.request, # TODO: remove
...

This got me to thinking that it would be very useful if the (X)HTML view provided information like:

Request	Response

GET /api/foo HTTP/1.1	200 OK HTTP/1.1

Accepts: text/html, text/plain	Content-Type: text/html

Content-Length: 2048

( no body )	{ "foo": "bar" }

This would help the potential API consumer to understand the HTTP call in detail, thus helping them to implement their client. Was something like this included at some point?

Also, the API I am working on now dumps a ton of data to the user, this makes a huge scrolling page, I would like to present the return body in a scrolling div. This is something I can handle myself, in my own template, but wondered if formatting like the above would be appreciated upstream.

Last but not least, the data is JSON, so it might be nice to provide syntax highlighting for the data dump (in the scrolling div). There are javascript libraries that could be included easily to provide highlighting for JSON, XML, YAML etc. Again, is this something that would be appreciated upstream?