This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-06-08
Channels
- # asami (15)
- # babashka (123)
- # beginners (174)
- # calva (4)
- # cider (6)
- # cljdoc (4)
- # cljs-dev (4)
- # cljsrn (18)
- # clojure (268)
- # clojure-australia (1)
- # clojure-europe (107)
- # clojure-ireland (5)
- # clojure-nl (2)
- # clojure-uk (18)
- # clojured (1)
- # clojurescript (21)
- # conjure (4)
- # cursive (38)
- # data-science (1)
- # datahike (6)
- # datomic (4)
- # events (1)
- # fulcro (9)
- # graalvm (16)
- # helix (6)
- # honeysql (4)
- # instaparse (3)
- # jobs (1)
- # observability (15)
- # pathom (7)
- # pedestal (15)
- # polylith (9)
- # practicalli (1)
- # re-frame (6)
- # remote-jobs (2)
- # specter (7)
- # sql (16)
- # tools-deps (1)
- # vim (5)
- # xtdb (1)
i have a routes namespace where i define some routes (def routes #{["/Team" :get (conj api-interceptors
entities/team-stubs)]})` and an entities namespace where i implement that route. how can i use the url-for-routes
in the entities namespace to include links to other endpoints without causing a circular reference? (def url-for (route/url-for-routes routes/app-routes))
it seems like this would be the most common usage but it results in circular references and thus cannot be done ... what can i do short of putting the entire app in one namespace? is there a solution to this common issue?
@lucian303 have you tried routes/url-for
? If so, why doesn’t it meet your needs? It only requires a route name (https://github.com/pedestal/pedestal/blob/d20065013abf5d3793ae5301e18a2398707fa2a9/samples/http2/src/hp/service.clj#L13).
thank you @ddeaguiar that's what i was looking for. i hadn't tried it because i didn't understand that part of the documentation and i thought the reference to url-for
was the url-for
created using url-for-routes
in the example code at http://pedestal.io/guides/defining-routes
I have this issue too @lucian303 You can use route/url-for from inside requests But it's not a final solution
Not exactly inside the request map
But there is the route/*url-for*
available, if you are inside a interceptor/handler called after the standard route interceptor
https://github.com/pedestal/pedestal/blob/master/route/src/io/pedestal/http/route.clj#L374
- we had a handler that use route/url-for
to generate and send a email to the user
- we changed our approach. moved this handler into a kafka batch processing, providing the same parameters that the http-handler used to have (query-params etc)
- the handler stopped to work because it uses route/url-for and it's not available
- once we pretend to move many endpoints into kafka, we choose to provide the route/*url-for*
inside the kafka processing context.
@ddeaguiar any feedback about my usage?
I think that’s fine. route/url-for
was intended to be used within request execution.
I don't know/understand why it's not a value in the context/request, or at least a public var.
I use (with-bindings {#'route/*url-for* my-custom-url-for}
in some places in my code
pedestal.route is an awesome lib, but without docs is really hard to use also, there is some design deicisions that i can't understand
i c. i'll try that. i was already trying all kinds of require hacks and such so any solution at this point, no matter how hacky, is most welcome
@lucian303 you can use promise/deliver to avoid circular deps
thank you @ddeaguiar that's what i was looking for. i hadn't tried it because i didn't understand that part of the documentation and i thought the reference to url-for
was the url-for
created using url-for-routes
in the example code at http://pedestal.io/guides/defining-routes