Sumo Rest - The easiest way to build RESTful API servers in #Erlang


By elbrujohalcon | Published: December 3, 2015



Sumo Rest

Generic Cowboy handlers to work with Sumo DB

 

We, at Inaka, build our RESTful servers on top of cowboy. We use sumo_db to manage our persistence and trails together with cowboy-swagger for documentation.

Soon enough, we realized that we were duplicating code everywhere. Not every endpoint in our APIs is just a CRUD for some entity, but there are definitely lots of them in every server. As an example, most of our servers provide something like the following list of endpoints:

  • GET /users
  • POST /users
  • PUT /users/:id or PATCH /users/:id
  • DELETE /users/:id
  • GET /users/:id

 

To avoid (or at least reduce) such duplication, we started using mixer.

Eventually, all applications shared that same base_handler, so we decided to abstract that even further. Into its own app: sumo_rest.



Follow Erlang Central:


Have an Erlang Question?

Reach out to the Erlang community