Openroad - cowboy response middleware

Hello, Erlang community! I would like to share a small library that I’ve created to make building cowboy web apps a little more convenient.

It provides a data-centric api to make html, json, text, or other data type responses. Just plug in the cowboy middleware and you are ready to go! Like I said, it is all data! Essentially, all you have to do is add a resp field in the proper format to the cowboy request. openroad will takes care of the rest.

Some additional features:

  • Set cookie in response
  • Set headers in response
  • Composite template views

The README goes into a lot more detail on how to use it.

openroad can be easily integrated into new and existing cowboy web applications. You can live without openroad, but it is likely you’ll write similar code when making your own web app.

openroad uses erlydtl for templating, and jsone for json encoding. Both things that are expected/tolerated in any web framework. Actually, I like to think of openroad as the response half of a web framework. I thought about breaking up the erlydtl and jsone parts into their own respective libraries, but I decided against it for the time being.

Feature wise, it is close to being 100% complete. The additions I can foresee are more content types for responses and making the json library configurable. I want to keep it small and composable. Contributions and suggestions are very welcome though!

One thing I could use help on is how to mock cowboy requests for unit tests.

Git - Hex

P.S. The name openroad is meant to be a western vibe, which I thought suited a library intended to be a cowboy extension.

5 Likes