App → Route Handlers
Route Handlers
Register a handler for any HTTP-style method. Routes support typed params, wildcards, and optional Deflate compression per route.
Signatures
GET app:Get(route, handler, options?)
POST app:Post(route, handler, options?)
PUT app:Put(route, handler, options?)
DELETE app:Delete(route, handler, options?)
Parameters
| Parameter | Type | Description |
|---|---|---|
route | string | Route pattern. Supports typed params, wildcards, globs, and inline constraints. See Router. |
handler | function | Modern (req, res) or legacy (Player, Payload, req, res). Detected automatically by parameter count via debug.info. |
options.compress | boolean? | Enable LZ77 Deflate on the response. GET and POST only. Default false. |
Handler conventions
Use the modern (req, res) form — it gives you req.player and req.raw automatically. The legacy four-argument form is supported for backwards compatibility.
-- Modern (recommended)
app:Get("player/:id=number", function(req, res)
res:Send({ id = req.params.id, name = req.player.Name })
end)
-- Legacy
app:Get("player/:id=number", function(Player, Payload, req, res)
res:Send({ id = req.params.id })
end)
Method conventions
| Method | Body | Response | Notes |
|---|---|---|---|
| GET | optional | any data | |
| POST | required | encoded data (Base64 / Deflate) | |
| PUT | required | boolean? or nil | table body warned and stripped |
| DELETE | optional | boolean? or nil | table body warned and stripped |
Compression
-- Deflate compression on a single route
app:Get("leaderboard", function(req, res)
res:Send(bigLeaderboardTable)
end, { compress = true })
-- The client receives a compressed buffer; Network decompresses it automatically.
-- No API change needed on the client side.
See also
← App · Middleware | run code before handlers · Request Object | params, query, data · Response Object | Send, Error, Status · Router | full route pattern syntax · Codec | compression internals