Skip to content
Amir Yasin edited this page Mar 12, 2015 · 1 revision

Specifying a path

Paths in FRHTTP are strings.

/samples/hello.world

In this simple path, if FRHTTP were running locally on port 8001, you could navigate your browser to http://localhost:8001/samples/hello.world to execute this route.

In addition to basic paths, FRHTTP's router supports path variables and wildcards. Path variables are indicated by placing a : at the beginning of the path element (the sections between the slashes). For example:

/samples/:clientId/home

In this example, :clientId represents a URL variable. You can access these variables by asking for server.CONSTANTS.URL_VARS in your when blocks (described later).

In addition to variables, paths also support wildcards. A wildcard is indicated with a * and must be the last element in the path (everything past the wildcard is effectively ignored).

/samples/files/*

In this example, any request to a path under /samples/files will result in this route being executed.

Path selection rules

FRHTTP uses a best fit method to select the path to execute. This means that it prefers the "most precise" match. Consider the following routes:

/clients/*
/clients/:clientId/files
/client/22/files

If the user navigates to /client/22/files the third route will be executed, even though all 3 technically match the route. This is because the last route is the "most precise" fit.

Clone this wiki locally