Jug stands for Just Unified Galloping. Okay, okay, it’s just a play on words coming from a Flask (Python) background.

Jug is my attempt to create a simple small web framework that allows you to turn your (existing) R functions into an API. Having the wonderful httpuv package at my disposal made this very easy for me.

So, how does this work?

Let’s say I have the following function:

say_hello_to<-function(name) paste("Hello", name)

Sometimes you would be in a situation where you want to send a GET request to a server and let a function (let’s say the one above) return it’s result. Thus, I want to expose the above function to allow HTTP GET requests to acces it. Using Jug I could do something like this:


jug() %>%
  gett("/", decorate(say_hello_to)) %>%
Serving the jug at

However, when I run this code and post a GET request to the URL, the following happens:

$ curl
ERROR: argument "name" is missing, with no default

Obviously, because the function say_hello_to requires the parameter name. A second attempt has better results:

$ curl
Hello Bart

However, besides exposing exsting fuctions, Jug is quite flexible. It has a middleware system, which allows to build up a (http) web server layer by layer. For example:


jug() %>%
  postt("/", function(req, res){
  }) %>%
  gett("/", function(req, res){
    paste("Hello",my_first_name, my_last_name)
  }) %>%

$ curl --data "first_name=Bart&last_name=Blitzers"
$ curl
Hello Bart Blitzers

So, enough for now. More on this later…

A (very) early version can be found at github.com/Bart6114/jug.