README.md

RestRserve

R build status CRAN status codecov License Lifecycle: maturing gitter tinyverse

RestRserve is an R web API framework for building high-performance AND robust microservices and app backends. With Rserve backend on UNIX-like systems it is parallel by design. It will handle incoming requests in parallel - each request in a separate fork (all the credits should go to Simon Urbanek).

Quick start

Creating application is as simple as:

library(RestRserve)
app = Application$new()

app$add_get(
  path = "/health", 
  FUN = function(.req, .res) {
    .res$set_body("OK")
  })

app$add_post(
  path = "/addone", 
  FUN = function(.req, .res) {
    result = list(x = .req$body$x + 1L)
    .res$set_content_type("application/json")
    .res$set_body(result)
  })


backend = BackendRserve$new()
backend$start(app, http_port = 8080)

Test it with curl:

curl localhost:8080/health
# OK
curl -H "Content-Type: application/json" -d '{"x":10}' localhost:8080/addone
# {"x":11}

Autocomplete

Using convenient .req, .res names for handler arguments allows to leverage autocomplete.

Learn RestRserve

Features

Installation

From CRAN

install.packages("RestRserve", repos = "https://cloud.r-project.org")

Docker

Debian and Alpine based images are available from docker-hub: https://hub.docker.com/r/rexyai/restrserve/

docker pull rexyai/restrserve

Or install specific version:

docker pull rexyai/restrserve:0.4.0-minimal

Contributing

Guidelines for filing issues / pull requests - CONTRIBUTING.md.

Acknowledgements

Known limitations

Related projects



Try the RestRserve package in your browser

Any scripts or data that you put into this service are public.

RestRserve documentation built on Jan. 13, 2021, 7:05 p.m.