This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-07-17
Channels
- # aleph (7)
- # announcements (1)
- # aws (12)
- # beginners (118)
- # calva (15)
- # cider (17)
- # clj-kondo (1)
- # cljdoc (11)
- # cljsrn (1)
- # clojure (108)
- # clojure-dev (32)
- # clojure-europe (3)
- # clojure-italy (4)
- # clojure-kc (1)
- # clojure-nl (4)
- # clojure-portugal (1)
- # clojure-spec (29)
- # clojure-uk (69)
- # clojurescript (91)
- # cursive (14)
- # datomic (8)
- # emacs (13)
- # figwheel-main (12)
- # graphql (4)
- # jackdaw (1)
- # jobs (14)
- # lambdaisland (3)
- # luminus (3)
- # nyc (1)
- # off-topic (14)
- # onyx (23)
- # pedestal (8)
- # re-frame (4)
- # reitit (3)
- # shadow-cljs (6)
- # spacemacs (7)
- # specter (2)
- # tools-deps (3)
- # unrepl (4)
- # vim (7)
- # xtdb (10)
Hey folks, I am trying to use expand-route
with no success. It`s my first time to use pedestal and I am a bit lost.
(def routes
(route/expand-routes
#{["/" :get [common-interceptors] `home-page]
["/about" :get [common-interceptors] `about-page]
["/user" :post [common-interceptors] `create-user]}))
1. Caused by java.lang.AssertionError
Assert failed: Route name or handler appears more than once in the
route spec: [[#Interceptor{:name
:io.pedestal.http.body-params/body-params} #Interceptor{:name
:io.pedestal.http/html-body} #Interceptor{:name }]] (nil?
(seen-route-names rname))
the error seems obvious but i don`t know how to get right of it, anything I tried so far, I get other kind of error. Any help about the right way to use expand-routes
?
@quieterkali, your service is based on the pedestal-service template then io.pedestal.http/default-interceptors
is being called then you don’t need route/expand-routes
. In terms of your routes, it looks you are using the table route syntax but it’s not complete correct. It should look something like this:
(def routes
(route/expand-routes
#{["/" :get (conj common-interceptors `home-page)]
["/about" :get (conj common-interceptors `about-page)]
["/user" :post (conj common-interceptors `create-user)}))
oh, how did you noticed that my project was based on pedestal service template? curiosity 😄 Can I use nested level route with this template?
Lucky guess 🙂. Table route syntax does not support nested routes. However, I find it to be the preferred route syntax because it’s easier to reason about (for me anyways).
curious, I find the hierarchy more difficult to follow once it grows beyond a handful of layers or a dozen routes total. I like being able to see all the routes laid out in full.