Have at it!
Congrats!
This is maybe more of a #leiningen question, but I stumbled on it when working through the “Creating a project” tutorial.... Is there something you need to do so that
(def w (->Widget))
works out of the box after starting with lein repl
?Maybe I goofed some set-up, because I thought I’ve had this kind of thing work before (i.e., lein
loading you into the project namespace, vs. needing to explicitly load things).
You need to lead the namespace first, and then make sure that that namespace is “current” in your repl.
So, if you just started with lein repl
, you could do (require '[myproj.core])
and then (in-ns myproj.core)
Or use the fully qualified name, (def w (myproj.core/->Widget))
Thanks. I ended up doing the require
approach, since for some reason the qualified namespace didn’t work. (That’s why I was wondering if I haven’t goofed my lein config somehow, unrelated to arachne.)
Well you have to require it just to cause that NS to load... the functions in it aren't available until something such as a require has caused it to be loaded
I see the difference now. If I lein repl
for my other projects, by default I’m going into proj.core
and have immediate qualified access to proj.core/
ns functions. But with the arachne config, I’m going into arachne.run
, and my proj.core
isn’t immediately available. Different from my usual workflow, since the require
is implicit.
BtW, I’m assembling typo fixes as I work through the tutorial. Is fork and pull request the best way to submit those?
Yes, thank you! I know there's probably a lot of them :)
@luke (really) off-topic, but I'd love it if you could expand on your workflow for writing and building the docs website
I need to get around to building a docs website for Lumo and I liked Arachne's layout & organization
@anmonteiro It’s pretty straightforward. I write the docs in markdown, then use a tool called “mkdocs” to build them into a static html site. I use the “codox” Clojure lib to generate API documentation (also static HTML). I have a script (which you can see at https://github.com/arachne-framework/arachne-docs/blob/master/deploy.sh), to merge the results of the two builds together and deploy them using Github Pages.
took me like a day to get set up, would recommend :thumbsup:
awesome, I'll explore. thanks!
An observation on the http tutorial: The way the greet handler is written makes me believe that localhost:8000/greet/ will return "Who's there?", but it seems that with a path of "/greet/:name" there needs to be something in :name, or it won't match.
@madstap ah, great point. I forgot to put an example URL in there to make that clear. I’ll fix that in my next update. Thanks!
@luke I don't think I explained it very well...
(defn greeter
[req]
(let [name (get-in req [:path-params :name])]
{:status 200
:body (if (empty? name)
"Who's there!?" ; This branch is never taken.
(str "Hello, " name "!"))}))
(h/endpoint :get "/greet/:name" (h/handler 'myproj.core/greeter))
;; Because "/greet/:name" matches urls like site/greet/aleks,
;; but doesn't match site/greet or site/greet/
;; So :name can never be an empty string, nor nil