Sitevision Developer
Log in

Log in

request (req)

The req object is a representation of the HTTP-request.

Properties

req.params

Object that contains parameters passed to a route. The object contains route parameters ('/user/:id'), query string parameters and values in the request body from POST, PUT and DELETE.

req.cookies

Object that contains cookies from the request.

req.session

Session data is stored and accessed through the req.session property. Session attributes are namespaced for WebApps/RESTapps, i.e. "global" session attributes cannot be accessed. Note that session data must be JSON serializable.

req.hostname

Hostname from the HTTP request.

req.protocol

Protocol from the request (http or https).

req.secure

Boolean shorthand checking req.protocol === 'https'.

If a load balancer or proxy is used, make sure that the client request protocol is forwarded to Sitevision.

req.method

HTTP method of the request.

req.path

Contains the path part of the request URL (the string used to resolve a route).

req.uri [@since 2023.04.1]

The client request uri (the uri that triggered rendering of this app). Note! The uri is not always equal to "the uri of current page".

req.serverside [@since 2023.08.1]

Whether the request is a server-side one or not. State is true when the RestApp is invoked via RestAppInvoker.

Methods

req.updateSession() [@since 2023.03.1]

Re-synchronizes local req.session state with the global/shared App session state. Typically needed when multiple apps are executed intertwined

req.invalidateSession()

Invalidates current session.

req.file(fileParameterName)

Method to retrieve files from a multipart request. Files are exposed as sv:temporaryFile-nodes.

FileUtil and ImageUtil provide useful methods when working with temporary file nodes.

req.header(name)

Request headers from the HTTP-request

Did you find the content on this page useful?