This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-04-10
Channels
- # announcements (4)
- # beginners (116)
- # boot (4)
- # calva (63)
- # cider (8)
- # clara (20)
- # cljdoc (10)
- # cljsrn (69)
- # clojure (115)
- # clojure-austin (1)
- # clojure-dev (4)
- # clojure-finland (1)
- # clojure-italy (3)
- # clojure-nl (6)
- # clojure-russia (10)
- # clojure-uk (84)
- # clojurescript (28)
- # cursive (14)
- # data-science (1)
- # datascript (1)
- # datomic (11)
- # duct (3)
- # emacs (13)
- # figwheel-main (11)
- # fulcro (4)
- # graphql (6)
- # jackdaw (2)
- # jobs (23)
- # jobs-rus (1)
- # kaocha (11)
- # lein-figwheel (13)
- # leiningen (55)
- # luminus (14)
- # lumo (22)
- # off-topic (121)
- # pathom (19)
- # re-frame (6)
- # reagent (3)
- # reitit (22)
- # remote-jobs (10)
- # ring-swagger (1)
- # shadow-cljs (67)
- # slack-help (5)
- # spacemacs (1)
- # sql (18)
- # vim (28)
- # yada (2)
@roklenarcic oh, would you have a time to do a PR to fix that?
@ikitommi I think the issue is that I'm using rring/create-resource-handler
outside of a router, I am using it as a default handler. This is why path-params key is missing and path is always nil.
oh, sure. so, you could write it as:
(rring/ring-handler
(rring/router
[["/status" {:get {:handler (json/wrap-json-response status-handler)}}]
["/api" {:middleware (api-middleware logger)}
["" {:get {:handler api-handler}}]]]
(rring/create-resource-handler {}))
{:middlewre [wrap-gzip wrap-head]})
that's the same?
but router doesn't take a default handler
the second param is opts map
and ring-handler takes a default handler but not an opts map
(ring/ring-handler
(ring/router
[["/status" {:get {:handler (json/wrap-json-response status-handler)}}]
["/api" {:middleware (api-middleware logger)}
["" {:get {:handler api-handler}}]]])
(ring/create-resource-handler {})
{:middlewre [wrap-gzip wrap-head]})
yeah, but that's what I had and that doesn't work
because resource handler doesn't receive :path-params
in request map
It looks for path param :
(empty keyword) in :path-params
key in request
this is absent
(def app
(ring/ring-handler
(ring/router
["/status" {:get {:handler (constantly {:status 200, :body "ok"})}}])
(ring/create-resource-handler {:path "/"})))
(app {:request-method :get, :uri "/docs"})
let me try
code here:
(if (resource-response (join-paths path file))
(response/redirect (join-paths uri file))
is odd though. Why use a different expression for full path in if
and the clauseLooks like it works now
in doc it says | :path | optional path to mount the handler to. Works only if mounted outside of a router.
should probably say that it's mandatory outside of a router