Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Mock request

Methods

req.header(name: string)

Receiver MockRequest · Returns any

A request header value (case-insensitive), or () if absent.

req.json(path: string)

Receiver MockRequest · Returns any

The value at a dotted JSON path in the body (object→map, array, number, bool, null()). Errors if the path is missing.

Example

#![allow(unused)]
fn main() {
assert(req.json("call.from")).equals("+49301234567");
}

req.query(name: string)

Receiver MockRequest · Returns any

A query-string parameter value, or () if absent.

Fields

req.body

Receiver MockRequest · Returns string

The raw request body.

req.method

Receiver MockRequest · Returns string

The request method (upper-case).

req.path

Receiver MockRequest · Returns string

The request path.