UNPKG

stick

Version:

JSGI based webapp framework

160 lines 9.09 kB
<!DOCTYPE html > <html lang="de" dir="ltr"> <head> <title>stick/middleware/mount - Stick API</title> <link rel="shortcut icon" href="http://ringojs.org/favicon.ico" type="image/x-icon" /> <link rel="icon" href="http://ringojs.org/favicon.ico" type="image/x-icon" /> <link rel="stylesheet" href="../../../static/style.css" /> <link rel="stylesheet" href="../../../static/jsdoc.css" /> <script type="text/javascript" src="../../../static/jquery.js"></script> <script type="text/javascript" src="../../../static/jsdoc.js"></script> <script> $(document).ready(jsdocSetup); </script> </head> <body> <div class="wrap"> <div class="main"> <div class="content"> <h1 class="modulename">Module stick/middleware/mount</h1> <div class="fileoverview"> <p>This module provides middleware for mounting other applications on a specific URI path or virtual host.</p> <p>Applying this middleware adds a <code>mount</code> method to the application. The mount method takes a path or virtual host specification and an application as arguments. If the spec is a string, it is interpreted as the URI path on which the app will be mounted. If it is an object, it may contain <code>path</code> or <code>host</code> properties that will be matched against the URI path and <code>Host</code> header of incoming requests. <em>Note that virtual host based mounting has not been tested so far.</em></p> <p>Mounting one application within another causes the <code>scriptName</code> and <code>pathInfo</code> properties in the request object to be adjusted so that the mounted application receives the same pathInfo as if it was the main application. This means that forward and reverse request routing will usually work as expected.</p> <p>This middleware maintains an index mapping applications to mount points which can be accessed using the <a href="#lookup">lookup</a> function. The [stick/helpers] module provides higher level functions for this which include support for the route middleware.</p> </div> <div> <h4> Example </h4> <pre class="sh_javascript sh_sourceCode">app.configure("mount"); app.mount("/wiki", module.resolve("vendor/ringowiki"));</pre> </div> <div class="classoverview"> <div> <h3>Functions</h3> <ul class="propertyoverview"> <li> <a href="#lookup" class="jsdoc-title"> lookup</a>(target) </li> <li> <a href="#middleware" class="jsdoc-title"> middleware</a>(next, app) </li> </ul> </div> <div class="classes"> </div> </div> <hr/> <div class="details"> <!-- tpl-docitem --> <div> <div class="docitem" docitem="lookup"> <h3> <span class="itemtitle"><a id="lookup" href="#lookup" class="itemtitle itemname">lookup</a></span> <span class="itemtitle light">(target)</span></h3> <div> <p>Return the URI path of a mounted application</p> </div> <div> <h4>Parameters</h4> <table> <tr> <td></td> <td class="paramname">target</td> <td>a mounted JSGI application</td> </tr> </table> </div> <div> <h4>Returns</h4> <table> <tr> <td></td> <td>the URI path of the application, or ""</td> </tr> </table> </div> </div> <hr/> </div> <!-- tpl-docitem --> <div> <div class="docitem" docitem="middleware"> <h3> <span class="itemtitle"><a id="middleware" href="#middleware" class="itemtitle itemname">middleware</a></span> <span class="itemtitle light">(next, app)</span></h3> <div> <p>Middleware to mount other application on specific URI paths or virtual hosts.</p> </div> <div> <h4>Parameters</h4> <table> <tr> <td>Function</td> <td class="paramname">next</td> <td>the wrapped middleware chain</td> </tr> <tr> <td>Object</td> <td class="paramname">app</td> <td>the Stick Application object</td> </tr> </table> </div> <div> <h4>Returns</h4> <table> <tr> <td>Function</td> <td> a JSGI middleware function</td> </tr> </table> </div> </div> <hr/> </div> </div> </div> </div> <div class="menu" style="margin-top: 1em; font-size: 13px;"> <p> <a class="repositoryname" href="../../../index.html">Stick API </a> </p> Filter:<br /> <input id="jsdoc-leftnavsearch" type="search" size="14"> <ul class="jsdoc-leftnav leftnav"> <li><a href="../../../stick/index.html"> stick </a></li> <li><a href="../../../stick/helpers/index.html"> stick/helpers </a></li> <li><a href="../../../stick/middleware/index.html"> stick/middleware </a></li> <li><a href="../../../stick/middleware/basicauth/index.html"> stick/middleware/basicauth </a></li> <li><a href="../../../stick/middleware/continuation/index.html"> stick/middleware/continuation </a></li> <li><a href="../../../stick/middleware/error/index.html"> stick/middleware/error </a></li> <li><a href="../../../stick/middleware/etag/index.html"> stick/middleware/etag </a></li> <li><a href="../../../stick/middleware/gzip/index.html"> stick/middleware/gzip </a></li> <li><a href="../../../stick/middleware/method/index.html"> stick/middleware/method </a></li> <li><a href="../../../stick/middleware/mount/index.html"> stick/middleware/mount </a></li> <li><a href="../../../stick/middleware/notfound/index.html"> stick/middleware/notfound </a></li> <li><a href="../../../stick/middleware/params/index.html"> stick/middleware/params </a></li> <li><a href="../../../stick/middleware/profiler/index.html"> stick/middleware/profiler </a></li> <li><a href="../../../stick/middleware/render/index.html"> stick/middleware/render </a></li> <li><a href="../../../stick/middleware/requestlog/index.html"> stick/middleware/requestlog </a></li> <li><a href="../../../stick/middleware/route/index.html"> stick/middleware/route </a></li> <li><a href="../../../stick/middleware/session/index.html"> stick/middleware/session </a></li> <li><a href="../../../stick/middleware/static/index.html"> stick/middleware/static </a></li> <li><a href="../../../stick/middleware/upload/index.html"> stick/middleware/upload </a></li> </ul> </div> </div> </body> </html>