jsonapi_server: Start a JSONAPI server

View source: R/jsonapi_server.R

jsonapi_serverR Documentation

Start a JSONAPI server

Description

Start a JSONAPI server

Usage

jsonapi_server(port = 8000)

Arguments

port

(integer) the port to run the server on. default: 8000

Details

Right now, this function doesn't take arbitrary input, but instead serves the same content as this JSON API example https://github.com/endpoints/endpoints-example . Note that not all features are the same as the full endpoints-example, but most should work.

Right now, this function serves data from static, minified JSON files, so there's no dynamic database underneath.

Kill the server by CTRL+C, ESC or similar.

Examples

## Not run: 
if (interactive()) {
  # start a server in another R session
  jsonapi_server()

  # Back in this session ...
  # Connect
  (conn <- jsonapi_connect("http://localhost:8000"))

  # Get data
  conn$url
  conn$version
  conn$content_type
  conn$routes()
  conn$route("authors")
  conn$route("chapters")
  conn$route("authors/1")
  conn$route("authors/1/books")
  conn$route("chapters/5")
}

## End(Not run)

sckott/rjsonapi documentation built on May 20, 2022, 1:12 p.m.