ForgeTotal.js 5
en

Total.js 5

Catch many URLs with a wildcard route

Total.js 5 · total5@0.0.19 routing Executed against Total.js 5

A * as the last segment of a route matches any URL below that path. A route without the wildcard is more specific and wins, so you can handle the general case with the wildcard and add fixed routes for the exceptions. The request path is available in $.url.

controllers/docs.js
exports.install = function() {
	ROUTE('GET /docs/*', docs);
	ROUTE('GET /docs/changelog/', changelog);
};

function docs($) {
	$.json({ handler: 'docs', url: $.url });
}

function changelog($) {
	$.json({ handler: 'changelog' });
}