-
-
Save swannodette/351783 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns defn-test | |
(:use clj-html.core | |
[net.cgrand.moustache :only [app]] | |
[ring.adapter.jetty :only [run-jetty]] | |
[ring.util.response :only [response]])) | |
(defhtml application [text body] | |
[:html | |
[:head | |
[:title text]] | |
[:body | |
[:h3 text] | |
body]]) | |
(defhtml code-list [body] | |
[:ul body]) | |
(defhtml code-block [[code result]] | |
[:li [:pre code] [:pre ";; =>" result]]) | |
(defn test-fn* | |
[#^String text] | |
(response | |
(application text | |
(code-list (code-block text))))) | |
(def test-web | |
(app | |
["examples" [text #".*"]] {:get (fn [req] (test-fn* text))} | |
[#".*"] {:get ["all routes!"]})) | |
(defonce server (run-jetty #'test-web {:port 8080 :join? false})) |
["examples" [text #".*"]]
matches /examples/anything
but not /examples/anything/
nor /examples/anything/else...
However the #".*"
is redundant, just write ["examples" text]
.
[#".*"]
is likewise equivalent to [_]
but only matches /something
. If you want to match all urls you have to use [&]
.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
(declare test-web)
(def server (doto (Thread. #(run-jetty #'test-web {:port 8080})) .start))