Request class provides access to HTTP request data including headers, query parameters, request body, uploaded files, and cookies.
Importing
Properties
The complete URL of the request
HTTP method (GET, POST, etc.)
Unique identifier for the request
Reference to the HTTP context
URL and Path
url()
Get the complete URL including query string.Include query string in the URL
string
completeUrl()
Get the complete URL with protocol and host.Include query string in the URL
string
pathname()
Get the URL pathname without query string.string
protocol()
Get the request protocol (http or https).string
hostname()
Get the request hostname.string
host()
Get the request host including port.string
Query Parameters
qs()
Get all query string parameters.Record<string, any>
input()
Get a specific query parameter value.Parameter name
Default value if parameter is not present
any
Request Body
all()
Get all request body data.Record<string, any>
body()
Get the entire request body.Record<string, any>
only()
Get specific fields from the request body.Array of field names to extract
Record<string, any>
except()
Get all fields except specified ones.Array of field names to exclude
Record<string, any>
Route Parameters
params()
Get all route parameters.Record<string, any>
param()
Get a specific route parameter.Parameter name
Default value if parameter is not present
any
Headers
headers()
Get all request headers.Record<string, string>
header()
Get a specific header value.Header name (case-insensitive)
Default value if header is not present
string | undefined
Cookies
cookie()
Get a cookie value.Cookie name
Default value if cookie is not present
any
plainCookie()
Get a plain (unsigned) cookie value.Cookie name
Default value if cookie is not present
any
encryptedCookie()
Get an encrypted cookie value.Cookie name
Default value if cookie is not present
any
cookiesList()
Get all cookies as an object.Record<string, any>
File Uploads
file()
Get an uploaded file.Form field name
Validation options for the file
size: Maximum file sizeextnames: Allowed file extensions
MultipartFile | null
files()
Get multiple uploaded files.Form field name
Validation options for the files
MultipartFile[]
allFiles()
Get all uploaded files.Record<string, MultipartFile | MultipartFile[]>
Content Type
is()
Check if the request has a specific content type.Array of content types to check
string | boolean
types()
Get acceptable content types from the Accept header.string[]
accepts()
Check if the request accepts a specific content type.Array of content types to check
string | boolean
Request Validation
validateUsing()
Validate request data using a VineJS validator.VineJS validator instance
Optional validation options
errorReporter: Custom error reportermessagesProvider: Custom messages providerdata: Custom data to validate (defaults to request data)
Promise<T>
tryValidateUsing()
Validate request data without throwing errors.VineJS validator instance
Optional validation options
Promise<[ValidationError, null] | [null, T]>
Utilities
fresh()
Check if the request is fresh (for caching).boolean
stale()
Check if the request is stale.boolean
ajax()
Check if the request is an AJAX request.boolean
pjax()
Check if the request is a PJAX request.boolean
secure()
Check if the request is over HTTPS.boolean
ip()
Get the client IP address.string
ips()
Get all IP addresses from X-Forwarded-For header.string[]
subdomains()
Get request subdomains.string[]