This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-03-10
Channels
- # admin-announcements (2)
- # alda (16)
- # beginners (22)
- # boot (55)
- # cider (11)
- # cljs-dev (5)
- # cljsrn (7)
- # clojure (115)
- # clojure-art (1)
- # clojure-finland (3)
- # clojure-greece (18)
- # clojure-madison (2)
- # clojure-norway (2)
- # clojure-poland (50)
- # clojure-russia (122)
- # clojure-uk (9)
- # clojurescript (28)
- # core-async (7)
- # cursive (4)
- # data-science (4)
- # datomic (65)
- # devcards (3)
- # dirac (91)
- # editors (7)
- # emacs (9)
- # hoplon (1)
- # jobs (5)
- # jobs-discuss (10)
- # juxt (2)
- # keechma (7)
- # ldnclj (31)
- # leiningen (3)
- # off-topic (22)
- # om (129)
- # om-next (1)
- # onyx (6)
- # proton (15)
- # protorepl (2)
- # re-frame (49)
- # reagent (13)
- # remote-jobs (1)
- # ring-swagger (2)
- # yada (19)
FYI, I’m going to refactor boot-new
so it more closely matches the structure of boot/core
so it’ll be easier to merge in https://github.com/seancorfield/boot-new/issues/15
Feedback from Boot contributors welcome!
OK PR #428 passes the build now. If I get time, I’ll look at how to write tests for the boot new
stuff and integrate those as well (but I won’t have much time for that before the middle of next week — I only pushed on the integration PR today since @micha indicated he was going to attack the PRs this weekend )
Hey all, I’m trying to write a simple clojure app using boot & compojure. I can’t seem to boot up the server though - I’m sure it’s something simple
I have these two files: build.boot:
(set-env!
:source-paths #{"src"}
:resource-paths #{"resources"}
:dependencies '[[org.clojure/clojure "1.8.0"]
[ring-server "0.4.0"]
[compojure "1.5.0"]
[pandeiro/boot-http "0.7.3" :scope "test"]])
(require '[pandeiro.boot-http :refer :all])
(require '[produce.api :as api])
(deftask dev []
(comp
(serve :handler ‘api/handler
:reload true
:init 'api/init)
(wait)))
src/produce/api.clj
(ns produce.api
(:require [compojure.core :refer :all]))
(defroutes api
(GET "/greeting" []
"Hey!"))
(def handler api)
(defn init []
(println "initializing api"))
Yet when I run boot dev
I get the error:
Could not locate api__init.class or api.clj on classpath.
Can anyone spot what I’m doing wrong? If I run serve with no options, it doesn’t error, but that’s not super helpful 😉
Oh, facepalm - it does not run produce.api/init
, I was declaring the function incorrectly. Even after fixing the declaration I still get the same issue
Use the full symbol names in the serve
call: 'produce.api/api
and 'product.api/init
The handler and init values are resolved in a context that doesn't have the require alias.
I had tried that but at the time my init function was being declared as a var not a function
FWIW, you don't need the require
for produce.api
at all in build.boot
gotchya - so it was erring because the quoting the name doesn't use aliases? Or was I requiring & aliasing it wrong?
Because 'foo/bar
is just a symbol -- it evaluates to itself.
So you don't need a require in build.boot to reference it at all. You're just passing arbitrary symbols to the serve
task... which in turn resolves them in its own namespace.
followup question: do I need to pull in ring-server as a dependency? Or does boot-http come with one?
(I’m pretty much just going entirely off of those github repo, as it was the only example I could find that defined a dev task: https://github.com/borkdude/lein2boot)
I'm not familiar with boot-http so I'd have to try it and see (I tried out your code to figure out that first issue).
Commenting out the Ring server dependency doesn't break things so I guess you don't need it as a specific dependency.
Well I took it out and it still runs…. So I’m going to assume it’s not necessary. I thought it seemed extraneous, but I’m too new too all these libraries to make many assumptions
You do need compojure tho'
Is anyone aware of an example (or boot task/library) to run the agent for dirac devtools?
I guess the reason I asked was I’m not to sure how dependencies work. I know when I add them, and run boot, it will install them. If I take them out, does it remove them? Remove them from the class-path? Or do I need to manually remove it via the cli?
Dependencies are transitive. So if pandeiro.boot-http has its own dependency on ring-server, it will be pulled in if you depend on pandeiro.boot-http
Those dependencies are downloaded (once) and stashed locally (in your ~/.m2/repository cache).
Boot figures out the full dependency tree based on what you explicitly declare and downloads anything that is missing and then builds a classpath with all of the dependencies on it, then runs stuff.
If you want a different version of ring-server, you can declare that explicitly and then when you declare the pandeiro.boot-http dependency, you can exclude ring-server -- then you won't get that transitive version, you'll get your explicit version.
This is my first web-related clojure project, so sorry if these questions are painstakingly simple
Don't worry, the whole fun world of dependency management is something that you slowly get used to as you build bigger things with Clojure...
I use a "framework" of my own design for web apps -- it's essentially a bundle of Ring and Selmer (for web pages) and some dynamic routing logic -- so if you you ask for /greeting
it will look for app.controllers.greeting/default
and run that as a handler... if you ask for /greeting/hello
it will look for app.controllers.greeting/hello
and run that.
It's based on an MVC framework I built in 2009 for CFML and I ported it to Clojure a few years back.
There's a Boot template for new apps too.
I’m trying to avoid using any templated solutions for now because I obviously need to learn my fundamentals first
Feel free to ping me with my any questions -- DM if you want -- we've been using the CFML version in heavy production use for quite a while and we're transitioning to the Clojure version at the moment.
Hey @micha I sent a PR for boot-new
integration for consideration for 2.6.0 but wanted to let you know I’ll be AFK over the weekend, in case you have any questions and ping me … and I don’t seem to answer!
@seancorfield: awesome, i'll check it out tonight before the weekend
Hey boot people! I’ve been playing around with dirac (https://github.com/binaryage/dirac) which does some really cool experimental things with chrome devtools.