App → Request Object

Request Object

The req argument passed to every modern (req, res) handler. Contains everything about the incoming request — params, payload, query, and the player who sent it.

Fields

FieldTypeDescription
req.params {[string]: any} Named route params, already coerced to their declared type. :id=number arrives as a Lua number, not a string.
req.captures {any} Positional captures from wildcards (*) and globs (**) in the route pattern.
req.query {[string]: string} Query string params passed after ?, e.g. items?limit=10&page=2.
req.data any The raw body sent by the client. May be nil for GET / DELETE with no body.
req.player Player? The Player who fired this request. Only populated in modern (req, res) handlers.
req.raw Payload? The full raw payload table before routing. Only populated in modern handlers. Useful for Tamper or logging middleware.

Examples

-- typed param → arrives as number
app:Get("player/:id=number", function(req, res)
    print(req.params.id)        -- number, not string
    print(req.player.Name)      -- Player who sent the request
end)

-- wildcard capture
app:Get("zone/*/item/*", function(req, res)
    local zone, item = req.captures[1], req.captures[2]
end)

-- query string: GET("items?limit=10&page=2")
app:Get("items", function(req, res)
    local limit = tonumber(req.query.limit) or 20
end)

-- POST body
app:Post("buy", function(req, res)
    local itemId = req.data.itemId   -- from client body table
end)

See also

← App  ·  Route Handlers | registering GET/POST/PUT/DELETE  ·  Response Object | sending replies  ·  Router | param syntax, wildcards, constraints  ·  Types | full Payload and Request type definitions