Building Knod, a tiny HTTP server. Part 1: Introduction

While working through Facebook’s excellent React tutorial, I came across a common problem when developing and testing AJAX applications: Having some sort of rudimentary backend is necessary, or at the very least makes things easier. While options for http static servers are many, these only respond to GET requests and hence only get you part of the way there. The ideal solution would also respond to PUT, POST, and DELETE and would work with almost zero configuration.

People build quick prototypes often enough that I assumed a tool must exist for this very purpose. When I could not find such a tool, I built it. Knod, a tiny HTTP server for front-end development, was released on April 12 on RubyGems. The code is available here on GitHub. I limited myself to using the Ruby standard library and learned a lot in doing so. Subsequent posts in this series will detail what I learned about the request/response cycle, writing server tests, and turning a library into a useful command line tool.