Request Types
The incoming side of every route handler. Request is the parsed, player-attributed object your handler receives. Payload is the raw network envelope. RouteHandler is the function signature accepted by app:Get(), app:Post(), and so on.
Request
The req argument passed to every route handler. All fields are populated by the time your handler fires.
export type Request = {
params : { [string]: any }, -- named captures from the route pattern
captures : { any }, -- positional captures (wildcard segments)
query : { [string]: string },-- query string key/value pairs
data : any, -- request body (from Payload.data)
player : Player?, -- the Player who sent the request
raw : Payload?, -- the unmodified network envelope
}
| Field | Type | Description |
|---|---|---|
params | { [string]: any } | Named route captures, e.g. :id from "player/:id" arrives as req.params.id |
captures | { any } | Positional wildcard captures in order of appearance |
query | { [string]: string } | Parsed query string — "player/1?sort=asc" gives req.query.sort == "asc" |
data | any | The deserialized request body sent by the client |
player | Player? | The Roblox Player instance who fired the remote; nil for server-originated calls |
raw | Payload? | The raw Payload envelope before parsing — useful for debugging or reading version |
Payload
The wire envelope that travels over the remote. RoExpress parses this into Request automatically. You access it via req.raw when you need the original.
export type Payload = {
method : "GET" | "POST" | "PUT" | "DELETE",
route : string,
data : any?,
version : string?,
}
| Field | Type | Description |
|---|---|---|
method | "GET" | "POST" | "PUT" | "DELETE" | HTTP-style method sent by the client |
route | string | The route string as sent — e.g. "player/123" |
data | any? | Request body, or nil if none was sent |
version | string? | Optional client-set version tag for compatibility checks |
RouteHandler
The function type accepted by app:Get(), app:Post(), app:Put(), and app:Delete(). Two forms are accepted — use the compact form for new code.
-- Modern (compact) handler: (req, res) → ()
export type RouteHandlerCompact = (req: Request, res: Response) -> ()
-- Legacy handler: (Player, Payload, req, res) → ()
export type RouteHandlerLegacy =
(Player: Player, Payload: Payload, req: Request, res: Response) -> ()
-- Union | accepted by app:Get() / app:Post() etc.
export type RouteHandler = RouteHandlerCompact | RouteHandlerLegacy
(req, res) is cleaner and the recommended style for all new code. The legacy four-argument form is supported for backward compatibility with pre-v2.4 handlers.How to import types
local RoExpress = require(game.ReplicatedStorage.RoExpress)
-- Explicit type import
type Request = RoExpress.Request
type Payload = RoExpress.Payload
type RouteHandler = RoExpress.RouteHandler
-- Or use GetApp() which returns a fully-typed App — no annotation needed
local app = RoExpress.GetApp()
app:Get("player/:id", function(req, res)
res:Send({ id = req.params.id, player = req.player.Name })
end)
See also
← Types · Response Types | Response, NetworkResponse, MiddlewareHandler · Request Object | detailed field reference with examples · Route Handlers | registering handlers with app:Get() etc.