Matt Duran

I break things to learn how they work

Clacks in the Ethernet

Published on in 📝 Posts

I love Sir Terry Pratchet -- his ability to weave dry wit, comedy, and deep meaning is truly something that is difficult for many authors to acheive. By no means have I read the entire compendium of his Discworld series -- only a handful like Equal Rites and Night Watch -- but I appreciate him none the less.

The Clacks

A few months ago, I came across an older link on Boing Boing highlighting a way that someone came up to continue honoring Terry by sending "Clacks" in HTTP headers. In the Going Postal book, the postal system relies on a kind of visual semaphore to transmit messages back and forth, much like how ships are able to signal to each other with flags. My description does not do it justice, if you're interested in it, you shoul definitely go read it -- Going Postal won the 2005 Nebula award for Best Novel.

Back to the topic at hand, someone created http://www.gnuterrypratchett.com/ which outlined how to enable a type of "clacks" in HTTP headers in various platforms to keep the author's memory going. You could install the extension here and while doing your normal browsing, stumble across someone else who set up the headers. As the book says:

"A man is not dead while his name is still spoken." - Going Postal, Chapter 4 prologue

So how do you do this serverless?

I closed the page thinking the project was such a good idea, months went by, new projects were started and stopped, and I came back to it one day recently after coming across another site that triggered the extension. I really wanted to give this a shot but my site is hosted on Firebase -- how do you set up response headers for something that doesn't really have a server?

Checking the projects website, they had many guides on getting started with Nginx, Apache, HAProxy, and many more that folks had contributed, but nothing for Firebase. I did a bit of searching around and came across Google's documentation for configuring headers within Firebase. It can't be that easy, can it?

I modified my firebase.json file to include the below

        
          "headers": [
          {
            "source": "*",
            "headers": [
              {
                "key": "X-Clacks-Overhead",
                "value": "GNU Terry Pratchett"
              }
            ]
          }
        ]

        
      
Once I pushed it to firebase, I loaded my landing page and viola! I now have the clacks clacking away on my site! The firebase documentation has a great additional example of setting specific header values on certain object types like images, css files, fonts, etc. If you're interested in doing this, give it a shot -- if anything it's just a good way to get more familiar with what Firebase can do!