28 lines
10 KiB
HTML
28 lines
10 KiB
HTML
<!DOCTYPE html PUBLIC ""
|
|
"">
|
|
<html><head><meta charset="UTF-8" /><title>adl-support.core documentation</title><link rel="stylesheet" type="text/css" href="css/default.css" /><link rel="stylesheet" type="text/css" href="css/highlight.css" /><script type="text/javascript" src="js/highlight.min.js"></script><script type="text/javascript" src="js/jquery.min.js"></script><script type="text/javascript" src="js/page_effects.js"></script><script>hljs.initHighlightingOnLoad();</script></head><body><div id="header"><h2>Generated by <a href="https://github.com/weavejester/codox">Codox</a></h2><h1><a href="index.html"><span class="project-title"><span class="project-name">Adl-support</span> <span class="project-version">0.1.4-SNAPSHOT</span></span></a></h1></div><div class="sidebar primary"><h3 class="no-link"><span class="inner">Project</span></h3><ul class="index-link"><li class="depth-1 "><a href="index.html"><div class="inner">Index</div></a></li></ul><h3 class="no-link"><span class="inner">Topics</span></h3><ul><li class="depth-1 "><a href="intro.html"><div class="inner"><span>Introduction to adl-support</span></div></a></li></ul><h3 class="no-link"><span class="inner">Namespaces</span></h3><ul><li class="depth-1"><div class="no-link"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>adl-support</span></div></div></li><li class="depth-2 branch current"><a href="adl-support.core.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>core</span></div></a></li><li class="depth-2 branch"><a href="adl-support.filters.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>filters</span></div></a></li><li class="depth-2 branch"><a href="adl-support.forms-support.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>forms-support</span></div></a></li><li class="depth-2 branch"><a href="adl-support.print-usage.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>print-usage</span></div></a></li><li class="depth-2 branch"><a href="adl-support.rest-support.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>rest-support</span></div></a></li><li class="depth-2 branch"><a href="adl-support.tags.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>tags</span></div></a></li><li class="depth-2"><a href="adl-support.utils.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>utils</span></div></a></li></ul></div><div class="sidebar secondary"><h3><a href="#top"><span class="inner">Public Vars</span></a></h3><ul><li class="depth-1"><a href="adl-support.core.html#var-*warn*"><div class="inner"><span>*warn*</span></div></a></li><li class="depth-1"><a href="adl-support.core.html#var-compose-exception-reason"><div class="inner"><span>compose-exception-reason</span></div></a></li><li class="depth-1"><a href="adl-support.core.html#var-compose-reason-and-log"><div class="inner"><span>compose-reason-and-log</span></div></a></li><li class="depth-1"><a href="adl-support.core.html#var-do-or-log-and-return-reason"><div class="inner"><span>do-or-log-and-return-reason</span></div></a></li><li class="depth-1"><a href="adl-support.core.html#var-do-or-log-error"><div class="inner"><span>do-or-log-error</span></div></a></li><li class="depth-1"><a href="adl-support.core.html#var-do-or-return-reason"><div class="inner"><span>do-or-return-reason</span></div></a></li><li class="depth-1"><a href="adl-support.core.html#var-do-or-warn"><div class="inner"><span>do-or-warn</span></div></a></li><li class="depth-1"><a href="adl-support.core.html#var-do-or-warn-and-log"><div class="inner"><span>do-or-warn-and-log</span></div></a></li><li class="depth-1"><a href="adl-support.core.html#var-massage-params"><div class="inner"><span>massage-params</span></div></a></li><li class="depth-1"><a href="adl-support.core.html#var-massage-value"><div class="inner"><span>massage-value</span></div></a></li><li class="depth-1"><a href="adl-support.core.html#var-raw-massage-params"><div class="inner"><span>raw-massage-params</span></div></a></li><li class="depth-1"><a href="adl-support.core.html#var-raw-resolve-template"><div class="inner"><span>raw-resolve-template</span></div></a></li><li class="depth-1"><a href="adl-support.core.html#var-resolve-template"><div class="inner"><span>resolve-template</span></div></a></li></ul></div><div class="namespace-docs" id="content"><h1 class="anchor" id="top">adl-support.core</h1><div class="doc"><pre class="plaintext">Application Description Language support - utility functions likely
|
|
to be useful in user-written code.</pre></div><div class="public anchor" id="var-*warn*"><h3>*warn*</h3><h4 class="dynamic">dynamic</h4><div class="usage"></div><div class="doc"><pre class="plaintext">The idea here is to have a function with which to show warnings to the user,
|
|
which can be dynamically bound. Any binding should be a function of one
|
|
argument, which it should print, log, or otherwise display.</pre></div></div><div class="public anchor" id="var-compose-exception-reason"><h3>compose-exception-reason</h3><h4 class="type">macro</h4><div class="usage"><code>(compose-exception-reason exception intro)</code><code>(compose-exception-reason exception)</code></div><div class="doc"><pre class="plaintext">Compose and return a sensible reason message for this `exception`.
|
|
</pre></div></div><div class="public anchor" id="var-compose-reason-and-log"><h3>compose-reason-and-log</h3><h4 class="type">macro</h4><div class="usage"><code>(compose-reason-and-log exception intro)</code><code>(compose-reason-and-log exception)</code></div><div class="doc"><pre class="plaintext">Compose a reason message for this `exception`, log it (with its
|
|
stacktrace), and return the reason message.</pre></div></div><div class="public anchor" id="var-do-or-log-and-return-reason"><h3>do-or-log-and-return-reason</h3><h4 class="type">macro</h4><div class="usage"><code>(do-or-log-and-return-reason form)</code></div><div class="doc"><pre class="plaintext">Clojure stacktraces are unreadable. We have to do better; evaluate
|
|
this `form` in a try-catch block; return a map. If the evaluation
|
|
succeeds, the map will have a key `:result` whose value is the result;
|
|
otherwise it will have a key `:error` which will be bound to the most
|
|
sensible error message we can construct. Additionally, log the exception</pre></div></div><div class="public anchor" id="var-do-or-log-error"><h3>do-or-log-error</h3><h4 class="type">macro</h4><div class="usage"><code>(do-or-log-error form & {:keys [message error-return], :or {message (clojure.core/seq (clojure.core/concat (clojure.core/list (quote clojure.core/str)) (clojure.core/list "A failure occurred in ") (clojure.core/list (list (quote quote) form))))}})</code></div><div class="doc"><pre class="plaintext">Evaluate the supplied `form` in a try/catch block. If the
|
|
keyword param `:message` is supplied, the value will be used
|
|
as the log message; if the keyword param `:error-return` is
|
|
supplied, the value will be returned if an exception is caught.</pre></div></div><div class="public anchor" id="var-do-or-return-reason"><h3>do-or-return-reason</h3><h4 class="type">macro</h4><div class="usage"><code>(do-or-return-reason form intro)</code><code>(do-or-return-reason form)</code></div><div class="doc"><pre class="plaintext">Clojure stacktraces are unreadable. We have to do better; evaluate
|
|
this `form` in a try-catch block; return a map. If the evaluation
|
|
succeeds, the map will have a key `:result` whose value is the result;
|
|
otherwise it will have a key `:error` which will be bound to the most
|
|
sensible error message we can construct.</pre></div></div><div class="public anchor" id="var-do-or-warn"><h3>do-or-warn</h3><h4 class="type">macro</h4><div class="usage"><code>(do-or-warn form)</code><code>(do-or-warn form intro)</code></div><div class="doc"><pre class="plaintext">Evaluate this `form`; if any exception is thrown, show it to the user
|
|
via the `*warn*` mechanism.</pre></div></div><div class="public anchor" id="var-do-or-warn-and-log"><h3>do-or-warn-and-log</h3><h4 class="type">macro</h4><div class="usage"><code>(do-or-warn-and-log form)</code><code>(do-or-warn-and-log form intro)</code></div><div class="doc"><pre class="plaintext">Evaluate this `form`; if any exception is thrown, log the reason and
|
|
show it to the user via the `*warn*` mechanism.</pre></div></div><div class="public anchor" id="var-massage-params"><h3>massage-params</h3><div class="usage"></div><div class="doc"><pre class="plaintext">Sending empty strings, or numbers as strings, to the database often isn't
|
|
helpful. Massage these `params` and `form-params` to eliminate these problems.
|
|
We must take key field values out of just params, but we should take all other
|
|
values out of form-params - because we need the key to load the form in
|
|
the first place, but just accepting values of other params would allow spoofing.</pre></div></div><div class="public anchor" id="var-massage-value"><h3>massage-value</h3><div class="usage"><code>(massage-value k m)</code></div><div class="doc"><pre class="plaintext">Return a map with one key, this `k` as a keyword, whose value is the binding of
|
|
`k` in map `m`, as read by read.</pre></div></div><div class="public anchor" id="var-raw-massage-params"><h3>raw-massage-params</h3><div class="usage"><code>(raw-massage-params request entity)</code><code>(raw-massage-params request)</code></div><div class="doc"><pre class="plaintext">Sending empty strings, or numbers as strings, to the database often isn't
|
|
helpful. Massage these `params` and `form-params` to eliminate these problems.
|
|
Date and time fields also need massaging.</pre></div></div><div class="public anchor" id="var-raw-resolve-template"><h3>raw-resolve-template</h3><div class="usage"><code>(raw-resolve-template n)</code></div><div class="doc"><pre class="plaintext">FIXME: write docs</pre></div></div><div class="public anchor" id="var-resolve-template"><h3>resolve-template</h3><div class="usage"></div><div class="doc"><pre class="plaintext">FIXME: write docs</pre></div></div></div></body></html> |