forked from noir-clojure/noir
-
Notifications
You must be signed in to change notification settings - Fork 10
/
noir.core.html
44 lines (34 loc) · 6.16 KB
/
noir.core.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<!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 & 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 "/login"] {:as req} (println "hello " req))
=> (POST "/login" {:as req} (println "hello" 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 "/login"] (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 & 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 "/foo/:id" {id :id}) an unnamed route
(defpage [:post "/foo/:id"] {id :id}) a route that responds to POST
(defpage foo "/foo:id" {id :id}) a named route
(defpage foo [:post "/foo/:id"] {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 & 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 & 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 & 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 & [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 & [arg-map])</code></div><pre class="doc">given a named route, i.e. (defpage foo "/foo/:id"), 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}) => "/foo/3" </pre></div></div></body></html>