Learn R Programming

prairie (version 0.0.1.3)

method: Request Method

Description

Get information about a request such as method type, the requested resource uri, the query component, or the requset HTTP protocol.

Usage

method(x)

Arguments

x

A request object.

See Also

Other HTTP request request-line: query, uri

Examples

Run this code
# NOT RUN {
methodical <- route(
 c('GET', 'POST'),
 '^',
 function(req) {
   res <- response()

   if (method(req) == 'GET') {
     # handle when method is GET
     body(res) <- 'I got ya'

   } else {
     body(res) <- 'Washingtong or Huffington?'

   }

   res
 }
)

methodical_m <- mockup(methodical)

res <- methodical_m('GET', '/')
res

res <- methodical_m('POST', '/')
body(res)

# }

Run the code above in your browser using DataLab