This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-10-10
Channels
- # aleph (4)
- # beginners (32)
- # cider (12)
- # cljs-dev (56)
- # cljsrn (7)
- # clojars (3)
- # clojure (165)
- # clojure-dev (33)
- # clojure-germany (1)
- # clojure-italy (27)
- # clojure-russia (7)
- # clojure-spec (24)
- # clojure-uk (62)
- # clojurescript (37)
- # core-async (7)
- # core-matrix (1)
- # cursive (9)
- # data-science (8)
- # datomic (8)
- # duct (4)
- # events (1)
- # figwheel (7)
- # flambo (3)
- # fulcro (43)
- # hoplon (25)
- # jobs-discuss (8)
- # lein-figwheel (4)
- # luminus (2)
- # off-topic (35)
- # om (8)
- # om-next (3)
- # onyx (30)
- # pedestal (62)
- # portkey (2)
- # protorepl (2)
- # re-frame (40)
- # reagent (9)
- # shadow-cljs (123)
- # specter (30)
- # sql (22)
- # testing (1)
- # uncomplicate (40)
- # unrepl (3)
- # vim (13)
- # yada (5)
in terse syntax I get assertion error
Caused by: java.lang.AssertionError: Assert failed: This vector for the verb map has extra elements. The leftover elements are (my-ped.service/home-page) from the original data [my-ped.service/identity-ic my-ped.service/home-page]
and as for using multimethods as handlers Paul has closed my ticket saying that this behavior is not supported by design :robot_face:
I don’t agree with Paul on that one. I’ve added a comment to the issue explaining my reasoning.
I probably should have use ^:interceptors
in the first one instead of ^interceptors
.
I think this case we ve worked out should be reflected in doc , because now it says "The value of each key is either a handler function or a list of interceptors."
What happens if you try a vector like [:unique-route-name interceptor interceptor handler]
?
Thanks for trying those variations out. I added a docs issue: https://github.com/pedestal/pedestal-docs/issues/91
@mtnygard you know what? even using
(def routes
`[[["/" {:get ^{:interceptors [identity-ic]} [:my-route home-page]}
^:interceptors [(body-params/body-params) http/html-body]
["/about" {:get about-page}]]]])
identity-ic is not added into interceptors vector, checked it via expand-routes.{:get [:terminal-intercepted ^:interceptors [interceptor-1 interceptor-2] request-inspection]}
So it’s a boolean metadata flag for :interceptors
attached to an ordinary vector, nested inside the verb’s action vector
I will try to use table syntax for a while, it is clearly more obvious but also quite verbose
This sounds sarcastic when written in text, but I mean it sincerely. We’re always interested in better ways to use data to describe configuration like routes. If you are able to find a representation that reduces duplication but doesn’t create the confusing overloaded syntax of the terse format, please let me know. We can plug new routing parsers in pretty easily.
still working on the use of the router standalone: I am stuck on a weird thing that seems somehow intentional, it seems that a route defined for /foo/bar/ will only match /foo/bar (notice the missing trailing slash)?
well we at http://health-samurai.io often use https://github.com/niquola/route-map
Web servers historically treat that as an alias for some subordinate like /foo/bar/index.html
well our proxy rewrite reqs when they are missing the trailing /, that makes it tricky to use
But for an API, it’s not clear whether “/foo/bar/” should mean “/foo/bar” or “/foo/bar/some-default”
in a pure routing context, if the route is defined for /foo/bar/ it should match /foo/bar/
Hmm… I found this issue that claims trailing slashes should be supported now. https://github.com/pedestal/pedestal/issues/477
maybe there's some sanitizing done at a lower level in the http bits, but the router does not support it
I’m looking at the source now to figure out why Paul’s comment doesn’t match the behavior you’re seeing.
OK, it looks like that issue doesn’t really apply. It talks about routes defined with a trailing slash, but requests that don’t have it.