Viewing REST service responses in a browser

Have you ever had this experience? You’re debugging some RESTful service and trying to figure out why it’s returning 500s. So you dump the response body to STDOUT and HOLY HAND GRENADE THAT’S A LOT OF HTML!!! Wouldn’t it be nice if you could just look at it in a browser?

Here ya go:

Just drop that in your debug script, in your .irbrc, or make a Boson command out of it. Then call it with the HTML you want to view:

It even respects the BROWSER environment convention (well, sort of).

I’ve put the code on Gist as well.