Skip to content

Request

$bolt.method()

Get HTTP method.

m = $bolt.method()  # "GET", "POST", etc.

$bolt.path()

Get request path.

p = $bolt.path()  # "/users/123"

$bolt.param(cName)

Get URL parameter.

# Route: /users/:id
id = $bolt.param("id")

$bolt.query(cName)

Get query string parameter.

# URL: /search?q=hello&page=1
q = $bolt.query("q")        # "hello"
page = $bolt.query("page")  # "1"

$bolt.header(cName)

Get request header.

auth = $bolt.header("Authorization")
contentType = $bolt.header("Content-Type")

$bolt.body()

Get raw request body as string.

raw = $bolt.body()

$bolt.jsonBody()

Parse request body as JSON.

data = $bolt.jsonBody()
name = data[:name]

$bolt.formField(cName)

Get form field value from multipart form data.

username = $bolt.formField("username")
password = $bolt.formField("password")

$bolt.requestId()

Get unique request ID.

id = $bolt.requestId()  # "550e8400-e29b-41d4-a716-446655440000"

$bolt.clientIp()

Get client IP address.

ip = $bolt.clientIp()  # "192.168.1.100"