diff options
Diffstat (limited to 'README.md')
| -rw-r--r-- | README.md | 44 |
1 files changed, 43 insertions, 1 deletions
@@ -1,6 +1,6 @@ # Ruuter -A tiny, zero dependency, system-agnostic router for Clojure, ClojureScript, Babashka and NBB that operates with a simple data structure where each route is a map inside a vector. Yup, that's it. No magic, no bullshit. +A tiny, zero dependency, system-agnostic router for Clojure, ClojureScript, Babashka, Jank and NBB that operates with a simple data structure where each route is a map inside a vector. Yup, that's it. No magic, no bullshit. ## Installation @@ -109,6 +109,42 @@ You can also use Ruuter with [Babashka](https://github.com/babashka/babashka), b @(promise) ``` +### Setting up with [Jank](https://jank-lang.org) + +[Jank](https://jank-lang.org) is a native Clojure dialect on LLVM. Since Ruuter is written in `.cljc` with `:jank` reader conditionals, it works with Jank directly. + +**Note:** Ruuter requires a recent Jank build from source (latest main). The 0.1 Homebrew release has a `clojure.string` codegen bug that prevents `clojure.string` from loading. This is fixed on main. See the [Jank build instructions](https://github.com/jank-lang/jank/blob/main/compiler+runtime/doc/build.md) for details. + +Create a file (e.g. `main.jank`) and point `--module-path` at Ruuter's `src` directory: + +```clojure +(ns example.main + (:require [ruuter.core :as ruuter])) + +(def routes [{:path "/" + :method :get + :response {:status 200 + :body "Hi there!"}} + {:path "/hello/:who" + :method :get + :response (fn [req] + {:status 200 + :body (str "Hello, " (:who (:params req)))})}]) + +(def request {:uri "/hello/world" + :request-method :get}) + +(println (ruuter/route routes request)) +``` + +Run it with: + +```bash +jank run --module-path src main.jank +``` + +See the `examples/jank-test-project/` directory for a complete example. + ### Creating routes Like mentioned above, each route is a map inside a vector. Routes are matched using **best-match semantics** — the most specific route wins regardless of order. @@ -235,6 +271,9 @@ clojure -M:cljs-test # Babashka bb test + +# Jank +./jank_test.sh ``` ### Running Benchmarks @@ -248,4 +287,7 @@ clojure -M:cljs-bench && node bench-out/bench.js # Babashka bb bench + +# Jank +jank run --module-path src:bench jank_bench_runner.jank ``` |
