Chapter 11. Adding an HTTP interface to the cache
This chapter covers
- Writing efficient TCP servers in Erlang
- Adding a simple text-based TCP interface to the cache
- Creating your own OTP behaviours
- Writing a basic web server
- Adding a RESTful HTTP interface to the cache
In the previous chapters, you’ve implemented a nice cache application. The Erlware team plans to keep enhancing it over the coming months. One of the things they recognize about the Simple Cache application is that it has the potential to be useful for projects beyond Erlware. But currently an obstacle to wider adoption is that it only has an Erlang interface, which means it can only be directly used by other applications written in Erlang.
Production environments today often contain services written in a variety of different languages. Before publishing Simple Cache as open source, you should make it useful to systems implemented in other languages. The most natural way to achieve this is to implement one or more interfaces over well-known network protocols. In this chapter, you’ll first implement a simple text-based protocol over TCP as a warm-up exercise, and then you’ll create a RESTful HTTP interface for the same functionality.