Is there a sample ring + compojure server I can look at? :o
Something like this @zackteo? https://github.com/seancorfield/usermanager-example/ That's a bit more than just Ring + Compojure but it's a small working app with a DB.
That works! Probably a bit more complicated compared to what I need but should be okay
I don't understand what you're asking here, sorry.
Feel free to DM me if you have any Qs about it.
Or ask them here.
Will do!
i'm not sure if there's any convention but here is how i organize my test directories:
❯ tree test
test
├── acceptance
│ └── shell
│ ├── api_server_test.clj
│ └── cli_app_test.clj
└── unit
├── core
│ └── domain_test.clj
└── shell
└── utilities_test.clj
5 directories, 4 files
and i would override the default test
alias in deps.edn
with {:extra-paths ["test/acceptance" "test/unit"]
so that tools like Cursive can find these directories and automatically mark them as "Test Sources Root", which in turn enables other useful Cursive features (e.g., jumping between production and test namespaces, automatically creating test namespaces in the right directories via shortcuts, etc.)
this layout also works well with test runners such as Kaocha so that you will be able to run a particular kind of tests by specifying an id
that maps to a directory:
#kaocha/v1
{:tests [{:id :unit
:test-paths ["test/unit"]}
{:id :acceptance
:test-paths ["test/acceptance"]}]}
Having some difficulty in understanding what I need to do to get a POST working and how to go about checking it. Should I be writing my response as json with clojure.jata.json/write-str
@zackteo If you need something even more basic, you can omit compojure completely and build your own router as demonstrated here: https://github.com/kloimhardt/babashka-scittle-guestbook
Thank you! @borkdude
does this function already exist? does it have a conventional name?
(defn f
[g]
(fn [x] (g x) x))
g
side effectstap?
looks like doto
nice, this is it
Hey everyone, I have a problem with require one my files to another ont in the same project. this is how the project looks like :
.
├──src\c\g
└── do_lib
├──views
└── home.clj
└── assets.clj
the ns of assets.clj is: (ns c.g.do-lib.assets)
I want to require the assets file in the home file so I did: (:require [c.g.do-lib.assets :as assets])
when I try to eval the home ns I'm getting a syntax error Class Not Found Exception
then windows path of home.clj file directory on my computer then c.g.do-lib.assets
.
other requires that been imported don't make a problem.
what did I miss ?
thank you :)how is assets.clj a child of home.clj?
by mistake - things change here - let me change it back
typo? c.g.do-lib.assets vs cO.g.do-lib.assets?
hard to tell which is a typo in slack and which might be a typo in your source. c.g
vs co.g
can you post the full error message?
what's the ns did you put in home.clj
? from the dir tree it should be (ns c.g.do-lib.views.home)
Syntax error (ClassNotFoundException) compiling at (c:\Users\..\my-pro\src\c\g\do_lib\views\home.cljc:0:0). c.g.do_lib.assets
the ns I used for home.clj
is (ns c.g.do-lib.views.home)
the directory do-lib needs to be do_lib
(c:\Users\..\my-pro\src\c\g\do_lib\views\home.cljc:0:0)
it seems to be
just double check that namespaces have dashes, and the corresponding files/dirs have underscores
It's a common stumbling point
ah, good point. in your tree output it is with a hyphen and in the copied error it has an underscore. These copy paste mistakes can make diagnosing issues quite difficult
the tree output shold look like the directory exactly?
in the directory name it is do_lib
but I changed it in the namespace to be do-lib.
so the dir name is already do_lib
before ghadi's suggestion?
yes
maybe you haven't saved the file after changing the namespace?
hmm, have you tried to eval the home.clj file directly?
@myguidingstar - reopening and eval the file solved it. thank you all for the help 🙂
In the clojure core function sort-by
([keyfn ^java.util.Comparator comp coll]
(sort (fn [x y] (. comp (compare (keyfn x) (keyfn y)))) coll))
I'm not sure i understand the use of the dot here. I understand it to be related to java interopt. Is this a case of Member access ? e.g (.instanceMember instance args)*
(.instanceMember Classname args)* It's this one: `(. instance-expr (method-symbol args))`*
Calling the compare
method on comp, https://docs.oracle.com/javase/8/docs/api/java/util/Comparator.html#compare-T-T-
(.doThing obj a b c)
==
(. obj (doThing a b c))
==
in Java: obj.doThing(a, b, c)
ah ok, so comp here isn't clojures.core/comp. that was causing me some confusion
I was looking past the params