method: Request Method

Description Usage Arguments See Also Examples

Description

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

Usage

1
method(x)

Arguments

x

A request object.

See Also

Other HTTP request request-line: query, uri

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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)

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