This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-02-10
Channels
- # asami (2)
- # babashka (28)
- # beginners (91)
- # calva (38)
- # cider (7)
- # clj-kondo (20)
- # cljfx (3)
- # clojure (88)
- # clojure-austin (1)
- # clojure-australia (2)
- # clojure-bay-area (10)
- # clojure-europe (68)
- # clojure-france (8)
- # clojure-italy (14)
- # clojure-nl (4)
- # clojure-sanfrancisco (1)
- # clojure-uk (14)
- # clojurescript (37)
- # clojureverse-ops (14)
- # clojurewerkz (1)
- # clr (1)
- # conjure (13)
- # cursive (10)
- # datascript (30)
- # datomic (6)
- # emacs (13)
- # exercism (3)
- # fulcro (10)
- # graalvm (4)
- # graphql (2)
- # instaparse (5)
- # jobs (3)
- # kaocha (10)
- # off-topic (20)
- # pathom (17)
- # polylith (7)
- # re-frame (25)
- # remote-jobs (1)
- # shadow-cljs (60)
- # spacemacs (5)
- # specter (1)
- # startup-in-a-month (1)
- # tools-deps (48)
- # vim (4)
- # xtdb (11)
Hi, I was wondering if any folk had experience with running the re-frame template as full-stack (e.g. using the +handler extra). I am trying to make an app where there’s the main route, which would be an SPA powered by reframe, and an /api route, that has some calls made directly to the server. I can’t quite seem to make it work, though, and am unsure if I’m understanding that +handler extra correctly.
I don’t think I’ve heard of the +handler extra, what is that?
It adds compojure, so that the resulting app has both a clj/app and cljs/app namespace. With compojure, it setups the server and defines basic routing:
(defroutes routes
(GET "/" [] (resource-response "index.html" {:root "public"}))
(resources "/")
(not-found "Page not found"))
Oh, it’s a luminus thing. Gotcha, that makes sense now.
or not luminus, re-frame itself I guess?
And this is likely just me not getting a concept, but if i add the route (GET "/api" [] "api a go")
it just returns a blank page. It looks like it’s still trying to have re-frame handle the routing for this path and not be server-side.
Ok, re-reading your original post, that should have been clear to me. (Long day 😛 )
Ok, so how are you hitting that /api
endpoint?
Are you making an ajax call from the browser or just going to it directly?
Actually, I should back up and review my compojure stuff, just a sec
evaluate (not-found "Page not found")
returns. i think you need a bit more structure than you're giving there
We’ve switched to reitit and now my compojure-foo is rusty.
You might want to have a look at https://github.com/weavejester/compojure/wiki/Getting-Started
If you haven’t done so already.
I.e. just start up a toy compojure project, without re-frame, and see how you get on with that.
((route/not-found "not here!") :dummy)
{:status 404,
:headers {"Content-Type" "text/html; charset=utf-8"},
:body "not here!"}
Compojure and re-frame fit together nicely, so once you’ve got the compojure side down I think you’ll have no problem putting the two together.
Ah, that’s a good idea. Thanks all! Yeah, I’m finding some of my confusion especially new…and should maybe step back from the template (for example: should I be running two repls with this template now, one for server and one for client?)
I’m running two repls, server and browser. I started from a different template tho.
I’d say start with the compojure one, get compojure working, then do the re-frame one, should get your feet off the ground.
@webmaster601 instead of using re-frame-template
, you might also want to use the templates used by luminus
... they are more backend focused. You can add +re-frame
to their templates