UNPKG

stick

Version:

JSGI based webapp framework

221 lines 12.9 kB
<!DOCTYPE html > <html lang="de" dir="ltr"> <head> <title>stick/helpers - 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/helpers</h1> <div class="fileoverview"> <p>A collection of helper functions that makes working with Stick middleware easier.</p> </div> <div class="classoverview"> <div> <h3>Functions</h3> <ul class="propertyoverview"> <li> <a href="#linkTo" class="jsdoc-title"> linkTo</a>(app, bindings, text) </li> <li> <a href="#redirectTo" class="jsdoc-title"> redirectTo</a>(app, bindings) </li> <li> <a href="#resolveApp" class="jsdoc-title"> resolveApp</a>(app) </li> <li> <a href="#urlFor" class="jsdoc-title"> urlFor</a>(app, bindings) </li> </ul> </div> <div class="classes"> </div> </div> <hr/> <div class="details"> <!-- tpl-docitem --> <div> <div class="docitem" docitem="linkTo"> <h3> <span class="itemtitle"><a id="linkTo" href="#linkTo" class="itemtitle itemname">linkTo</a></span> <span class="itemtitle light">(app, bindings, text)</span></h3> <div> <p>Return a link to an action configured using the <code>route</code> middleware.</p> <p>The link's URL is generated from the bindings argument as described for the <a href="#urlFor">urlFor helper</a>.</p> </div> <div> <h4>Parameters</h4> <table> <tr> <td>object|string</td> <td class="paramname">app</td> <td>the application to link to</td> </tr> <tr> <td>object</td> <td class="paramname">bindings</td> <td>an object containing the bindings for the target URL.</td> </tr> <tr> <td>string</td> <td class="paramname">text</td> <td>the link text.</td> </tr> </table> </div> </div> <hr/> </div> <!-- tpl-docitem --> <div> <div class="docitem" docitem="redirectTo"> <h3> <span class="itemtitle"><a id="redirectTo" href="#redirectTo" class="itemtitle itemname">redirectTo</a></span> <span class="itemtitle light">(app, bindings)</span></h3> <div> <p>Create a response that redirects the client to a different URL.</p> </div> <div> <h4>Parameters</h4> <table> <tr> <td>string|object</td> <td class="paramname">app</td> <td>either the URL as string or an app to be passed to `urlFor`</td> </tr> <tr> <td>bindings</td> <td class="paramname">bindings</td> <td>to pass to `urlFor` if first argument is an app.</td> </tr> </table> </div> <div> <h4>Returns</h4> <table> <tr> <td>object</td> <td> a JSGI response that will redirect the client to the specified target</td> </tr> </table> </div> </div> <hr/> </div> <!-- tpl-docitem --> <div> <div class="docitem" docitem="resolveApp"> <h3> <span class="itemtitle"><a id="resolveApp" href="#resolveApp" class="itemtitle itemname">resolveApp</a></span> <span class="itemtitle light">(app)</span></h3> <div> <p>Resolve a module name or module object to a JSGI application.</p> </div> <div> <h4>Parameters</h4> <table> <tr> <td></td> <td class="paramname">app</td> <td></td> </tr> </table> </div> </div> <hr/> </div> <!-- tpl-docitem --> <div> <div class="docitem" docitem="urlFor"> <h3> <span class="itemtitle"><a id="urlFor" href="#urlFor" class="itemtitle itemname">urlFor</a></span> <span class="itemtitle light">(app, bindings)</span></h3> <div> <p>Return a URL for an action configured using the <code>mount</code> and <code>route</code> middlewares.</p> <p>The <code>app</code> argument specifies the Stick application to link to, either as reference to the app itself or as module id of a module exporting the app as <code>app</code>. The <code>bindings</code> argument contains information needed to determine the target action within that application. Properties in the bindings argument are interpreted as follows:</p> <ul><li><p>The <code>action</code> property, if present, identifies the name of the action to link to. Action names are determined from the path arguments provided to the <code>route</code> middleware by removing all placeholders and the leading slash. For example, the name for an action routed with <code>/edit/:id</code> is "edit".</p></li> <li><p>Properties in the bindings object that have a placeholder with the same name in the target route are used to provide the value for this placeholder. For example, to URI path to an action in application <code>app</code> routed with "/edit/:id" with id <code>5</code> can be generated as follows:</p> <pre><code>urlFor(app, {action: "edit", id: 5})</code></pre></li> <li><p>All other properties in the bindings object are set as query parameters in the generated URL. For example, if "index" is a route with no placeholders then calling <code>urlFor("index", {do: "search"})</code> will generate the URL "/?do=search".</p></li></ul> <p>Note that the values for the current request are used as default values for <code>action</code> and route placehoders, so if you want to use to a different action or placeholder value you need to make that explicit.</p> </div> <div> <h4>Parameters</h4> <table> <tr> <td>object|string</td> <td class="paramname">app</td> <td>the application to link to</td> </tr> <tr> <td>object</td> <td class="paramname">bindings</td> <td>an object containing the bindings for the target URL.</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>