mockup: Mockup a Route

Description Usage Arguments Details Value Examples

Description

Creates a mockup of a route object. A mockup simulates what sort of response is generated by a route given a method, uri, and headers (optional).

Usage

1
mockup(r)

Arguments

r

A route object.

Details

Unfortunately, httpuv requires a least one header is specified. Therefore, headers defaults to and must have at least one field specified.

Value

A route mockup will return the response object returned by the route handler. However, if the method passed to the mockup is not handled by the route or if the path is not handled by the route a 404 response object with a description as the body is returned.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
mkup_logger <- mockup(
  route(
    'GET',
    '^',
    function(req) {
      print(req)
      response()
    }
  )
)

mkup_logger('GET', '/yellow/brick/path')
mkup_logger('GET', '/phonday', headers = list(Accepts = 'text/html'))

nteetor/prairie documentation built on May 24, 2019, 9:56 a.m.