Skip to content

Instantly share code, notes, and snippets.

@ddeaguiar
Last active August 29, 2015 14:14
Show Gist options
  • Save ddeaguiar/d8a6485d5dd81f5bf527 to your computer and use it in GitHub Desktop.
Save ddeaguiar/d8a6485d5dd81f5bf527 to your computer and use it in GitHub Desktop.
bidi routing sample
(ns routing.core
(:require [bidi.bidi :as b]
[bidi.ring :as r]
[ring.mock.request :refer [request] :rename {request mock-request}]))
(defn index-handler
[req]
{:status 200 :body "Index"})
(def handler-map
{:index index-handler})
(def routing-table
["/" {"index" :index
["articles/" :id "/article"] :article}])
(def handler
(r/make-handler routing-table handler-map))
(handler (mock-request :get "/index"))
;; {:status 200 :body "Index"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment