$request
Updated on Aug 19, 2025 6 minutes to readThe Request Plugin provides methods to access HTTP request data such as parameters, headers, cookies, files, and request metadata.
Methods
Method | Description |
---|---|
get | Retrieves all request parameters or a single parameter. |
getBodyParam | Retrieves a single body parameter by name. |
getBodyParams | Retrieves all body parameters. |
getContent | Retrieves the raw request body as a string. |
getContentType | Retrieves the content type of the request. |
getCookie | Retrieves a cookie object by name. |
getCookies | Retrieves all cookies. |
getCookieValue | Retrieves the value of a cookie by name. |
getFileByName | Retrieves an uploaded file by name. |
getHeader | Retrieves a single header value or all values. |
getHeaders | Retrieves all headers. |
getMethod | Retrieves the HTTP method of the request. |
getUserAgent | Retrieves the User-Agent string. |
getUserIp | Retrieves the client IP address. |
isDelete | Checks if the request method is DELETE. |
isGet | Checks if the request method is GET. |
isHead | Checks if the request method is HEAD. |
isPatch | Checks if the request method is PATCH. |
isPost | Checks if the request method is POST. |
isPut | Checks if the request method is PUT. |
post | Retrieves all POST parameters or a single parameter. |
Methods Details
get()
• Type
// Overload 1: no arguments
() => RequestCollection;
// Overload 2: with name and optional default value
(name: string, defaultValue?: any) => any;
• Details
Overload 1:
Returns a RequestCollection of all request parameters.
Overload 2:
Expects a parameter name and optional default value (default: null
).
Returns the parameter value or the default if not found.
getBodyParam()
• Type
(name: string, defaultValue?: any) => any
• Details
Expects a parameter name and optional default value (default: null
).
Returns the body parameter value or the default if not found.
getBodyParams()
• Type
() => RequestCollection
• Details
Returns a RequestCollection of all body parameters.
getContent()
• Type
() => string
• Details
Returns the raw request body as a string.
getContentType()
• Type
() => string | null
• Details
Returns the content type of the request or null
if not available.
getCookie()
• Type
(name: string) => Cookie | null
• Details
Expects a cookie name.
Returns a Cookie object or null
if not found.
getCookies()
• Type
() => Cookie[]
• Details
Returns all cookies as an array of Cookie objects.
getCookieValue()
• Type
(name: string, defaultValue?: any) => string | any
• Details
Expects a cookie name and optional default value (default: null
).
Returns the cookie value or the default if not found.
getFileByName()
• Type
() => UploadedFile | null
• Details
Returns an UploadedFile object for the uploaded file or null
if not found.
getHeader()
• Type
// Overload 1: return first header value
(name: string, defaultValue?: any, first?: true) => string;
// Overload 2: return all header values
(name: string, defaultValue?: any, first?: false) => string[];
• Details
Overload 1:
Expects a header name, optional default value (default: null
), and first set to true.
Returns the first header value as a string.
Overload 2:
Expects a header name, optional default value (default: null
), and first set to false.
Returns all header values as an array.
getHeaders()
• Type
() => HeaderCollection
• Details
Returns all request headers as a HeaderCollection.
getMethod()
• Type
() => string
• Details
Returns the HTTP method of the request (e.g., GET, POST, etc.).
getUserAgent()
• Type
() => string | null
• Details
Returns the User-Agent string or null
if not available.
getUserIp()
• Type
() => string | null
• Details
Returns the client IP address or null
if not available.
isDelete()
• Type
() => boolean
• Details
Returns true
if the request method is DELETE.
isGet()
• Type
() => boolean
• Details
Returns true
if the request method is GET.
isHead()
• Type
() => boolean
• Details
Returns true
if the request method is HEAD.
isPatch()
• Type
() => boolean
• Details
Returns true
if the request method is PATCH.
isPost()
• Type
() => boolean
• Details
Returns true
if the request method is POST.
isPut()
• Type
() => boolean
• Details
Returns true
if the request method is PUT.
post()
• Type
// Overload 1: no arguments
() => RequestCollection;
// Overload 2: with name and optional default value
(name: string, defaultValue?: any) => any;
• Details
Overload 1:
Returns a RequestCollection of all POST parameters.
Overload 2:
Expects a parameter name and optional default value (default: null
).
Returns the POST parameter value or the default if not found.