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/d7e859a2a2f121ae9107 to your computer and use it in GitHub Desktop.
Save dustingetz/d7e859a2a2f121ae9107 to your computer and use it in GitHub Desktop.
Pedestal expanded routes
(def routes
  (expand-routes
   `[[["/echo" {:any page/echo}]
      ["/api" {:get api-get}
       ^:interceptors [(body-params/body-params)
                       pedestal-util/auto-content-type
                       pedestal-util/combine-body-params]

       ["/questions" {:get questions-get :post questions-post}
        ["/:id" {:get question-item-get}]
        ]

       ["/friends" {:get friends-get :post friends-post}
        ["/:id" {:get friend-item-get}]]

       ]]]))
streaker-service.routes> (clojure.pprint/pprint routes)
({:route-name :streaker-service.page/echo,
  :path-re #"/\Qecho\E",
  :method :any,
  :path "/echo",
  :path-parts ["echo"],
  :path-params [],
  :interceptors
  [{:name :streaker-service.page/echo,
    :enter
    #<interceptor$before$fn__10535 io.pedestal.interceptor$before$fn__10535@4b424651>,
    :leave nil,
    :error nil}]}
 {:route-name :streaker-service.routes/api-get,
  :path-re #"/\Qapi\E",
  :method :get,
  :path "/api",
  :path-parts ["api"],
  :path-params [],
  :interceptors
  [{:name :io.pedestal.http.body-params/body-params,
    :enter
    #<interceptor$on_request$fn__10577 io.pedestal.interceptor$on_request$fn__10577@285ec75e>,
    :leave nil,
    :error nil}
   {:name :streaker-service.pedestal-util/auto-content-type,
    :enter nil,
    :leave
    #<interceptor$after$fn__10551 io.pedestal.interceptor$after$fn__10551@23845ac>,
    :error nil}
   {:name :streaker-service.pedestal-util/combine-body-params,
    :enter
    #<interceptor$on_request$fn__10577 io.pedestal.interceptor$on_request$fn__10577@487444d3>,
    :leave nil,
    :error nil}
   {:name :streaker-service.routes/api-get,
    :enter
    #<interceptor$before$fn__10535 io.pedestal.interceptor$before$fn__10535@58304b05>,
    :leave nil,
    :error nil}]}
 {:route-name :streaker-service.routes/questions-post,
  :path-re #"/\Qapi\E/\Qquestions\E",
  :method :post,
  :path "/api/questions",
  :path-parts ["api" "questions"],
  :path-params [],
  :interceptors
  [{:name :io.pedestal.http.body-params/body-params,
    :enter
    #<interceptor$on_request$fn__10577 io.pedestal.interceptor$on_request$fn__10577@285ec75e>,
    :leave nil,
    :error nil}
   {:name :streaker-service.pedestal-util/auto-content-type,
    :enter nil,
    :leave
    #<interceptor$after$fn__10551 io.pedestal.interceptor$after$fn__10551@23845ac>,
    :error nil}
   {:name :streaker-service.pedestal-util/combine-body-params,
    :enter
    #<interceptor$on_request$fn__10577 io.pedestal.interceptor$on_request$fn__10577@487444d3>,
    :leave nil,
    :error nil}
   {:name :streaker-service.routes/questions-post,
    :enter
    #<interceptor$before$fn__10535 io.pedestal.interceptor$before$fn__10535@76b153fe>,
    :leave nil,
    :error nil}]}
 {:route-name :streaker-service.routes/questions-get,
  :path-re #"/\Qapi\E/\Qquestions\E",
  :method :get,
  :path "/api/questions",
  :path-parts ["api" "questions"],
  :path-params [],
  :interceptors
  [{:name :io.pedestal.http.body-params/body-params,
    :enter
    #<interceptor$on_request$fn__10577 io.pedestal.interceptor$on_request$fn__10577@285ec75e>,
    :leave nil,
    :error nil}
   {:name :streaker-service.pedestal-util/auto-content-type,
    :enter nil,
    :leave
    #<interceptor$after$fn__10551 io.pedestal.interceptor$after$fn__10551@23845ac>,
    :error nil}
   {:name :streaker-service.pedestal-util/combine-body-params,
    :enter
    #<interceptor$on_request$fn__10577 io.pedestal.interceptor$on_request$fn__10577@487444d3>,
    :leave nil,
    :error nil}
   {:name :streaker-service.routes/questions-get,
    :enter
    #<interceptor$before$fn__10535 io.pedestal.interceptor$before$fn__10535@2f98e3b7>,
    :leave nil,
    :error nil}]}
 {:route-name :streaker-service.routes/question-item-get,
  :path-re #"/\Qapi\E/\Qquestions\E/([^/]+)",
  :method :get,
  :path-constraints {:id "([^/]+)"},
  :path "/api/questions/:id",
  :path-parts ["api" "questions" :id],
  :path-params [:id],
  :interceptors
  [{:name :io.pedestal.http.body-params/body-params,
    :enter
    #<interceptor$on_request$fn__10577 io.pedestal.interceptor$on_request$fn__10577@285ec75e>,
    :leave nil,
    :error nil}
   {:name :streaker-service.pedestal-util/auto-content-type,
    :enter nil,
    :leave
    #<interceptor$after$fn__10551 io.pedestal.interceptor$after$fn__10551@23845ac>,
    :error nil}
   {:name :streaker-service.pedestal-util/combine-body-params,
    :enter
    #<interceptor$on_request$fn__10577 io.pedestal.interceptor$on_request$fn__10577@487444d3>,
    :leave nil,
    :error nil}
   {:name :streaker-service.routes/question-item-get,
    :enter
    #<interceptor$before$fn__10535 io.pedestal.interceptor$before$fn__10535@71a2b52d>,
    :leave nil,
    :error nil}]}
 {:route-name :streaker-service.routes/friends-post,
  :path-re #"/\Qapi\E/\Qfriends\E",
  :method :post,
  :path "/api/friends",
  :path-parts ["api" "friends"],
  :path-params [],
  :interceptors
  [{:name :io.pedestal.http.body-params/body-params,
    :enter
    #<interceptor$on_request$fn__10577 io.pedestal.interceptor$on_request$fn__10577@285ec75e>,
    :leave nil,
    :error nil}
   {:name :streaker-service.pedestal-util/auto-content-type,
    :enter nil,
    :leave
    #<interceptor$after$fn__10551 io.pedestal.interceptor$after$fn__10551@23845ac>,
    :error nil}
   {:name :streaker-service.pedestal-util/combine-body-params,
    :enter
    #<interceptor$on_request$fn__10577 io.pedestal.interceptor$on_request$fn__10577@487444d3>,
    :leave nil,
    :error nil}
   {:name :streaker-service.routes/friends-post,
    :enter
    #<interceptor$before$fn__10535 io.pedestal.interceptor$before$fn__10535@2b90b07f>,
    :leave nil,
    :error nil}]}
 {:route-name :streaker-service.routes/friends-get,
  :path-re #"/\Qapi\E/\Qfriends\E",
  :method :get,
  :path "/api/friends",
  :path-parts ["api" "friends"],
  :path-params [],
  :interceptors
  [{:name :io.pedestal.http.body-params/body-params,
    :enter
    #<interceptor$on_request$fn__10577 io.pedestal.interceptor$on_request$fn__10577@285ec75e>,
    :leave nil,
    :error nil}
   {:name :streaker-service.pedestal-util/auto-content-type,
    :enter nil,
    :leave
    #<interceptor$after$fn__10551 io.pedestal.interceptor$after$fn__10551@23845ac>,
    :error nil}
   {:name :streaker-service.pedestal-util/combine-body-params,
    :enter
    #<interceptor$on_request$fn__10577 io.pedestal.interceptor$on_request$fn__10577@487444d3>,
    :leave nil,
    :error nil}
   {:name :streaker-service.routes/friends-get,
    :enter
    #<interceptor$before$fn__10535 io.pedestal.interceptor$before$fn__10535@57423850>,
    :leave nil,
    :error nil}]}
 {:route-name :streaker-service.routes/friend-item-get,
  :path-re #"/\Qapi\E/\Qfriends\E/([^/]+)",
  :method :get,
  :path-constraints {:id "([^/]+)"},
  :path "/api/friends/:id",
  :path-parts ["api" "friends" :id],
  :path-params [:id],
  :interceptors
  [{:name :io.pedestal.http.body-params/body-params,
    :enter
    #<interceptor$on_request$fn__10577 io.pedestal.interceptor$on_request$fn__10577@285ec75e>,
    :leave nil,
    :error nil}
   {:name :streaker-service.pedestal-util/auto-content-type,
    :enter nil,
    :leave
    #<interceptor$after$fn__10551 io.pedestal.interceptor$after$fn__10551@23845ac>,
    :error nil}
   {:name :streaker-service.pedestal-util/combine-body-params,
    :enter
    #<interceptor$on_request$fn__10577 io.pedestal.interceptor$on_request$fn__10577@487444d3>,
    :leave nil,
    :error nil}
   {:name :streaker-service.routes/friend-item-get,
    :enter
    #<interceptor$before$fn__10535 io.pedestal.interceptor$before$fn__10535@3f2ffc54>,
    :leave nil,
    :error nil}]})
nil
streaker-service.routes> 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment