Skip to content

Instantly share code, notes, and snippets.

@dustingetz
Last active August 29, 2015 14:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dustingetz/00552baac21c8615bedc to your computer and use it in GitHub Desktop.
Save dustingetz/00552baac21c8615bedc to your computer and use it in GitHub Desktop.
(defn route2 [root]
  (let [coll-route (keyword root)
        coll-handler (fn [req] {:ok :ok})]
    `~[(str "/" root) {:get [coll-route coll-handler]}]))


(def routes2
  (expand-routes
   `[[["/api" {:get api-get}
       ~(route2 "questions")
       ]]]))
streaker-service.routes> (-> (route2 "questions")
                             (clojure.pprint/pprint))
["/questions"
 {:get
  [:questions
   #<routes$route2$coll_handler__28266 streaker_service.routes$route2$coll_handler__28266@11c2ceab>]}]
nil
streaker-service.routes> (clojure.pprint/pprint routes2)
({:route-name :streaker-service.routes/api-get,
  :path-re #"/\Qapi\E",
  :method :get,
  :path "/api",
  :path-parts ["api"],
  :path-params [],
  :interceptors
  [{:name :streaker-service.routes/api-get,
    :enter
    #<interceptor$before$fn__10535 io.pedestal.interceptor$before$fn__10535@42fbb35f>,
    :leave nil,
    :error nil}]}
 {:route-name :questions,
  :path-re #"/\Qapi\E/\Qquestions\E",
  :method :get,
  :path "/api/questions",
  :path-parts ["api" "questions"],
  :path-params [],
  :interceptors [nil]})
nil
@dustingetz
Copy link
Author

 {:route-name :questions,
  :path-re #"/\Qapi\E/\Qquestions\E",
  :method :get,
  :path "/api/questions",
  :path-parts ["api" "questions"],
  :path-params [],
  :interceptors
  [{:name :questions,
    :enter
    #<interceptor$before$fn__10535 io.pedestal.interceptor$before$fn__10535@938bae4>,
    :leave nil,
    :error nil}]}

@dustingetz
Copy link
Author

(defn route3 [root]
  (let [coll-route (keyword root)
        coll-handler (fn [req] {:ok :ok})]
    [(str "/" root) {:get [coll-route `(identity ~coll-handler)]}]))


(def routes
  (expand-routes
   `~[[["/api" {:get 'api-get}
        (route3 "questions")
        ]]]))

@dustingetz
Copy link
Author

 {:route-name :questions,
  :path-re #"/\Qapi\E/\Qquestions\E",
  :method :get,
  :path "/api/questions",
  :path-parts ["api" "questions"],
  :path-params [],
  :interceptors
  [{:name :questions,
    :enter
    #<interceptor$before$fn__10535 io.pedestal.interceptor$before$fn__10535@60d3ff5b>,
    :leave nil,
    :error nil}]}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment