On the value of poking around

Posted by walwoodr on April 7, 2017

Are you a teapot? Because this Google page is. And so can your route’s status response be.

While learning about Rack, I was poking around at the methods that Rack gives to your response object, and as I scanned through the methods, one caught my eye:

:i_m_a_teapot? :i_m_a_teapot?

This little easter egg led me on a bit of a chase whereby I discovered that this refers to a status code that your server passes to the client. It’s a 400 status, meaning the page is a client error. In this case, error 418 is the “I’m a teapot” error. The origin of this error is an April Fool’s Day joke, but it’s also an honest to goodness response status that you can use. As you can see, Google has. Also, apparently, Stack Overflow.

After my discovery, I poked at it a bit more:

resp.status = 418; resp.i_m_a_teapot? => true

The web is a wild and wonderful place.