Permalink
Switch branches/tags
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
44 lines (34 sloc) 6.16 KB
<!DOCTYPE html>
<html><head><link href="css/default.css" rel="stylesheet" type="text/css"><script src="js/jquery.min.js" type="text/javascript"></script><script src="js/page_effects.js" type="text/javascript"></script><title>noir.core documentation</title></head><body><div id="header"><h1><a href="index.html">Noir 1.3.0-beta1 API documentation</a></h1></div><div class="sidebar" id="namespaces"><h3>Namespaces</h3><ul><li><a href="noir.cookies.html"><span>noir.cookies</span></a></li><li class="current"><a href="noir.core.html"><span>noir.core</span></a></li><li><a href="noir.options.html"><span>noir.options</span></a></li><li><a href="noir.request.html"><span>noir.request</span></a></li><li><a href="noir.response.html"><span>noir.response</span></a></li><li><a href="noir.server.html"><span>noir.server</span></a></li><li><a href="noir.server.handler.html"><span>noir.server.handler</span></a></li><li><a href="noir.session.html"><span>noir.session</span></a></li><li><a href="noir.statuses.html"><span>noir.statuses</span></a></li><li><a href="noir.util.crypt.html"><span>noir.util.crypt</span></a></li><li><a href="noir.util.gae.html"><span>noir.util.gae</span></a></li><li><a href="noir.util.test.html"><span>noir.util.test</span></a></li><li><a href="noir.validation.html"><span>noir.validation</span></a></li></ul></div><div class="sidebar" id="vars"><h3>Public Vars</h3><ul><li><a href="noir.core.html#var-compojure-route"><span>compojure-route</span></a></li><li><a href="noir.core.html#var-custom-handler"><span>custom-handler</span></a></li><li><a href="noir.core.html#var-custom-handler*"><span>custom-handler*</span></a></li><li><a href="noir.core.html#var-defpage"><span>defpage</span></a></li><li><a href="noir.core.html#var-defpartial"><span>defpartial</span></a></li><li><a href="noir.core.html#var-post-route"><span>post-route</span></a></li><li><a href="noir.core.html#var-pre-route"><span>pre-route</span></a></li><li><a href="noir.core.html#var-render"><span>render</span></a></li><li><a href="noir.core.html#var-url-for"><span>url-for</span></a></li></ul></div><div class="namespace-docs" id="content"><h2>noir.core documentation</h2><pre class="doc">Functions to work with partials and pages.
</pre><div class="public" id="var-compojure-route"><h3>compojure-route</h3><div class="usage"><code>(compojure-route compojure-func)</code></div><pre class="doc">Adds a compojure route fn to the end of the route table. These routes are queried after
those created by defpage and before the generic catch-all and resources routes.
These are primarily used to integrate generated routes from other libs into Noir.</pre></div><div class="public" id="var-custom-handler"><h3>custom-handler</h3><div class="usage"><code>(custom-handler &amp; args)</code></div><pre class="doc">Adds a handler to the end of the route table. This is equivalent to writing
a compojure route using noir's [:method route] syntax.
(custom-handler [:post &quot;/login&quot;] {:as req} (println &quot;hello &quot; req))
=&gt; (POST &quot;/login&quot; {:as req} (println &quot;hello&quot; req))
These are primarily used to interface with other handler generating libraries, i.e. async aleph handlers.</pre></div><div class="public" id="var-custom-handler*"><h3>custom-handler*</h3><div class="usage"><code>(custom-handler* route func)</code></div><pre class="doc">Adds a handler to the end of the route table. This is equivalent to writing
a compojure route using noir's [:method route] syntax, but allows functions
to be created dynamically:
(custom-handler* [:post &quot;/login&quot;] (fn [params] (println req)))
These are primarily used to interface with other dynamic handler generating libraries</pre></div><div class="public" id="var-defpage"><h3>defpage</h3><div class="usage"><code>(defpage &amp; args)</code></div><pre class="doc">Adds a route to the server whose content is the the result of evaluating the body.
The function created is passed the params of the request and the destruct param allows
you to destructure that meaningfully for use in the body.
There are several supported forms:
(defpage &quot;/foo/:id&quot; {id :id}) an unnamed route
(defpage [:post &quot;/foo/:id&quot;] {id :id}) a route that responds to POST
(defpage foo &quot;/foo:id&quot; {id :id}) a named route
(defpage foo [:post &quot;/foo/:id&quot;] {id :id})
The default method is GET.</pre></div><div class="public" id="var-defpartial"><h3>defpartial</h3><div class="usage"><code>(defpartial fname params &amp; body)</code></div><pre class="doc">Create a function that returns html using hiccup. The function is callable with the given name.
</pre></div><div class="public" id="var-post-route"><h3>post-route</h3><div class="usage"><code>(post-route &amp; args)</code></div><pre class="doc">Adds a route to the end of the route table and passes the entire request to
be desctructured and used in the body. These routes are guaranteed to be
evaluated after those created by defpage and before the generic catch-all and
resources routes.</pre></div><div class="public" id="var-pre-route"><h3>pre-route</h3><div class="usage"><code>(pre-route &amp; args)</code></div><pre class="doc">Adds a route to the beginning of the route table and passes the entire request
to be destructured and used in the body. These routes are the only ones to make
an ordering gaurantee. They will always be in order of ascending specificity (e.g. /* ,
/admin/* , /admin/user/*) Pre-routes are usually used for filtering, like redirecting
a section based on privileges:
(pre-route '/admin/*' {} (when-not (is-admin?) (redirect '/login')))</pre></div><div class="public" id="var-render"><h3>render</h3><div class="usage"><code>(render route &amp; [params])</code></div><pre class="doc">Renders the content for a route by calling the page like a function
with the given param map. Accepts either '/vals' or [:post '/vals']</pre></div><div class="public" id="var-url-for"><h3>url-for</h3><div class="usage"><code>(url-for route &amp; [arg-map])</code></div><pre class="doc">given a named route, i.e. (defpage foo &quot;/foo/:id&quot;), returns the url for the
route. If the route takes arguments, the second argument must be a
map of route arguments to values
(url-for foo {:id 3}) =&gt; &quot;/foo/3&quot; </pre></div></div></body></html>