The webpal-core extension defines a set of default routes for rendering pages and serving resources. These are tested against the URL in order, and the first matching route is invoked. WebPal allows editing of routes with a convenient table view in order to manage larger numbers of routes easily.
You can add custom routes by inserting a routes node in an extension like so:
Routes are matched against the URL in order specified, which means that to override existing routes, your custom extension should be placed before the webpal-core extension in order for the custom routes to be matched first.
A pre-defined route can be used to call specific named templates. For example, assume you wrote a template as such:
<xsl:template name="my-custom-sitemap">
<html>
<h1>Sitemap</h1>
<xsl:apply-templates select="/web/pages/page" mode="navigation"/>
</html>
</xsl:template>
you can now invoke it with this route:
/call-template/my-custom-sitemap
Caution: this default route allows anyone to invoke your named templates. Thus, all named templates should ensure that they do not expose the entire XML or any protected pages to the browser. For example, the following named template copies the entire XML, including settings, and code nodes, to the browser.
<xsl:template name="not-a-good-template">
<xsl:copy-of select="/web" />
</xsl:template>
If you need to disable any of the default routes, simply override them with new behaviour in your custom extension. For example the following route will redirect the call-template URL to the home page: