The request object
The request object represents an http request.
-
header
Returns the request headers. -
ip
Returns the remote IP address. -
param
Returns the request parameters. -
path
Returns the request path. -
redirect(location)
Redirects the users web browser to the specified location. -
responseMimeType(mimeType)
Sets the response content MIME type. -
site
Returns the site path. -
url
Returns the complete request url.
path
Returns the request path.
Syntax:
path → string
Returns:
The request path.
Example:
The following code prints the request path:
${liquidsite.request.path}
site
Returns the site path.
Syntax:
site → string
Returns:
The site path.
Example:
The following code prints the site path:
${liquidsite.request.site}
url
Returns the complete request url.
Syntax:
url → string
Returns:
The complete request url. It will not include request parameters or similar.
Example:
The following code prints the request URL:
${liquidsite.request.url}
ip
Returns the remote IP address. This is the IP address from where the request was supposedly sent. Note that the IP address may be in either IPv4 or IPv6 format depending on which protocol was used for the HTTP connection.
Syntax:
ip → string
Returns:
The remote IP address.
Example:
The following code prints the remote IP address:
${liquidsite.request.ip}
header
Returns the request headers.
Syntax:
header → hash model
Returns:
The request headers.
Example:
The following prints the value of the "Accept-Language" request header:
${liquidsite.request.header["Accept-Language"]}
param
Returns the request parameters.
Syntax:
param → hash model
Returns:
The request parameters.
Example:
The following prints the value of the "hello" request parameter:
${liquidsite.request.param.hello} is identical to
${liquidsite.request.param["hello"]}.
responseMimeType
Sets the response content MIME type. By default the HTML MIME type will be used.
Syntax:
responseMimeType(mimeType)
Parameters:
-
mimeType-- the new MIME type string
Example:
The following code modifies the output MIME type to normal text:
${liquidsite.request.responseMimeType("text/plain")}
redirect
Redirects the users web browser to the specified location. The location specified may be either a relative or an absolute URL. Note that page processing does not stop after calling this method. Also, a previous redirect may be cancelled by calling this method with an empty string.
Syntax:
redirect(location)
Parameters:
-
location-- the new location, or an empty string
Example:
The following code redirects to "www.liquidsite.net":
${liquidsite.request.redirect("http://www.liquidsite.net/")}
