Skip to content

Overview

Marc Worrell edited this page Jul 25, 2019 · 4 revisions

REST Toolkit

Webmachine and Cowmachine are not like the web frameworks you're used to. You can call Cowmachine a REST toolkit if you like, and we won't argue with you. Written in Erlang, Cowmachine is an application layer that adds server-side HTTP semantic awareness on top the HTTP web server and protocol handler software Cowboy, and provides a simple and clean way to connect that to your application‘s behavior.

Controllers

A Cowmachine application is a set of controllers, each of which is a set of functions over the state of the controller. We really mean functions here, not object-methods, infinite-server-loops, or any other such construction. This aspect of Cowmachine is one of the reasons why Cowmachine applications are relatively easy to understand and extend.

These functions give you a place to define the representations and other Web-relevant properties of your application's resources (as accessed by the controller) -- with the emphasis that the first-class things on the Web are resources and that their essential properties of interaction are already quite well defined and usefully constrained.

Referential Transparency

For most Cowmachine controllers, most of the functions are quite small and isolated. One of the nice effects of this is that a quick reading of a controller will give you an understanding of the application, its Web behavior, and the relationship between them. Since these functions are usually referentially transparent, Cowmachine controllers can be quite easy to test. There's no need for mock objects, fake database connections, or any other wastes of time when you can write tests against each component of your application in terms of the input and output to various functions.

HTTP Semantics

We believe that by giving Web developers a system with conventions that directly map to HTTP and REST, we help them to write and extend Web applications quickly while not dictating the shape of the rest of their application. The resulting applications are straightforward to examine and maintain, and have very easily understood HTTP semantics.

Clone this wiki locally