menu

SFRA / Server-side JS / Class: Route

Route

new Route(name, chain, req, res)

Parameters:
Name Type Description
name string

Name of the route, corresponds to the second part of the URL

chain Array.<function()>

List of functions to be executed

req Object

Request object

res Object

Response object

Source:

Methods

append(step) → {void}

Append a middleware step into current chain

Parameters:
Name Type Description
step function

New middleware step

Source:
Returns:
Type
void

done(req, res) → {void}

Last step in the chain, this will render a template or output a json string

Parameters:
Name Type Description
req Object

Request object

res Object

Response object

Source:
Returns:
Type
void

getRoute() → {function}

Create a single function that chains all of the calls together, one after another

Source:
Returns:

Function to be executed when URL is hit

Type
function

X Privacy Update: We use cookies to make interactions with our websites and services easy and meaningful, to better understand how they are used. By continuing to use this site you are giving us your consent to do this. Privacy Policy.