This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-02-19
Channels
- # announcements (1)
- # aws (9)
- # beginners (136)
- # boot (4)
- # cider (11)
- # clara (36)
- # clojure (337)
- # clojure-europe (5)
- # clojure-italy (3)
- # clojure-nl (2)
- # clojure-spec (9)
- # clojure-uk (112)
- # clojured (7)
- # clojurescript (93)
- # core-async (2)
- # cursive (30)
- # datomic (6)
- # duct (4)
- # emacs (2)
- # figwheel (1)
- # figwheel-main (7)
- # fulcro (153)
- # kaocha (1)
- # off-topic (12)
- # om-next (1)
- # pedestal (58)
- # planck (6)
- # re-frame (15)
- # reitit (11)
- # shadow-cljs (113)
- # spacemacs (1)
- # specter (3)
- # vim (8)
I’m trying to upgrade from pedestal 0.5.3 to 0.5.5, but it breaks some of our url-for
calls, raising this:
[{:type java.lang.IllegalArgumentException
:message "Don't know how to create ISeq from: clojure.lang.Keyword"
:at [clojure.lang.RT seqFrom "RT.java" 553]}]
:trace
[[clojure.lang.RT seqFrom "RT.java" 553]
[clojure.lang.RT seq "RT.java" 533]
[clojure.core$seq__5387 invokeStatic "core.clj" 137]
[clojure.core$empty_QMARK_ invokeStatic "core.clj" 6206]
[clojure.core$empty_QMARK_ invoke "core.clj" 6206]
[io.pedestal.http.route$link_str invokeStatic "route.clj" 252]
[io.pedestal.http.route$link_str invoke "route.clj" 230]
[io.pedestal.http.route$url_for_routes$fn__23926 doInvoke "route.clj" 369]
2019-02-19 15:01:27.001 DEBUG io.pedestal.http.route - {:in :link-str, :path-parts [:profile-handle], :context-path-parts [""], :line 247}
https://github.com/pedestal/pedestal/blob/0.5.5/route/src/io/pedestal/http/route.clj#L252
@kommen, sorry to hear about the issues you are having. Can you share an example url-for
call that is failing?
with this route: ["/:profile-handle" :get [profile/fetch profile/show] :route-name :show-named-profile]
hrm not sure. I drop that route and url-for
invocation into a new pedestal app using version 5.3 and I don’t see an issue.
(def my-url-for (route/url-for-routes (route/expand-routes routes)))
(my-url-for :show-named-profile :params {:profile-handle "foo"})
(def my-url-for (route/url-for-routes (table/table-routes routes)))
(my-url-for :show-named-profile :params {:profile-handle "foo"})
Ok, so I don’t see that behavior in the quick sample I generated but I generated it using the pedestal-service
template 0.5.5
and just updated the pedestal deps to 0.5.3
(def my-url-for (route/url-for-routes (route/expand-routes routes) :context ""))
(my-url-for :show-named-profile :params {:profile-handle "foo"})
IllegalArgumentException Don't know how to create ISeq from: clojure.lang.Keyword clojure.lang.RT.seqFrom (RT.java:550)
I’ll look into that further when I have a chance. I’m curious. Tracking down where :context ""
is being set is where I’d start looking
@ddeaguiar It looks like in pedestal 0.5.5 there is always a :context-path
on the request in https://github.com/pedestal/pedestal/blob/0.5.5/route/src/io/pedestal/http/route.clj#L209
so I guess this change here: https://github.com/pedestal/pedestal/commit/1d9083421cb8fa407d2093212e048e8420009c29#diff-9be1af57b1dfcec8ea9df18ac98e6777R152
Ok, thanks for digging through that. I’ll take a closer look. I’ll likely update the release notes with breaking change info and possibly open an issue around it.
Does anyone here have any basic examples of a pedestal CRUD project with mount/component and a database?
@decim creating such an example has been on my todo list for a while. If you have specific questions perhaps I can provide some guidance
@ddeaguiar i’m very much at the beginning of it. I’ve gone through the provided tutorials and I’m really just trying to figure out where to go, what all is necessary. Even something as simple as making a post. For starters i’d like to know how to just serve a basic index.html page from my resources folder. As I get a hold on things I’ll start to make blog posts for people in the future interested.
To serve files, add the :io.pedestal.http/resource-path
key to your system map. This will serve any files which match url from that dir
@ddeaguiar ok, nice. I really have to start looking through the source as well today. I’m coming from frameworks like ruby on rails so these libraries are very bare bones which isn’t a bad thing, it’s good to know exactly what’s taking place
I’ve experimented with component and pedestal quite a bit on various projects and I’m now more discerning about bringing the two together.
Pedestal provides a configuration map which you can append anything to at runtime, during system startup
They key concept is to create interceptors which provide access to those things you need (i.e., db connection, etc…)
If you need to start things, you already have the facilities to do it and append the started thing to the service map
My current line of thinking here is: - Define routes in one place - Limit components to external dependency needs (db, queueing system, etc…) - Use interceptors as glue to make those dependencies available on the context map and/or request - Do more processing in interceptors and limit handlers to formatting responses - With Component, have the Pedestal component depend on all other components and be responsible for putting their interceptor glue on the interceptor chain
Here are some examples of component+pedestal that I’ve tinkered with: https://github.com/pointslope/elements/blob/master/src/pointslope/elements/pedestal.clj#L1, https://github.com/ddeaguiar/component-pedestal
Hmm ok, I see. Looking at ‘elements’ now. It almost seems as if it’s better to start from scratch opposed to lein new pedestal service app-name
Again, take it with a grain of salt. Those projects are old and I’ve not had the need leverage component + pedestal lately
It’s perfectly acceptable to provision dependencies on system startup via -main
or run-dev
and add the interceptors which provide access to those started resources at that point.
@ddeaguiar yeah i’m wondering if using component or mount is overkill as well. I may be experimenting with too many things at once. long term for this toy project i’d like to use it but I suppose I shouldn’t fear a complete rewrite after I know what’s taking place. So you do prefer component over mount? I’ve seen a bit of discussion about that.