Fork me on GitHub
#bangalore-clj
<
2017-11-06
>
amarjeet09:11:45

Question: In an edn file, how can use a function from another file (from the same project)?

kumarshantanu16:11:38

@amarjeet Can you give an example?

amarjeet17:11:06

So, I created a vase app (lein new vase my-app) - here: https://github.com/amarjeet000/vase-demo . Vase does all the routing inside the edn file under the resources folder of the app. Now, I want to hit a 3rd party API. I want to use Exotel's cloud telephony API here. This, I believe, I can do inside the service.clj file only, using clj-http.client. If I do that, how to use the return values inside my api routes, which are in the end file?

amarjeet17:11:27

@kumarshantanu

amarjeet17:11:02

*api routes, which are in the EDN file

kumarshantanu17:11:18

I’m not familiar with Pedestal/Vase, but I’m puzzled why would you write any code in the EDN file. How do you get the stack trace for the code in such EDN files?

amarjeet17:11:03

Vase seems to be enforcing this approach. Route definition in pedestal is in the services.clj file only. Its just vase. And, routes defined inside the edn file are overriding the ones defined in the services.clj file in the vase app.

kumarshantanu17:11:06

@amarjeet If you look in the EDN file, there are forms starting with #vase/respond and #vase/transact etc. — those are reader literals

kumarshantanu17:11:33

for in-depth info on reader literals, you can start here — https://clojuredocs.org/clojure.core/*data-readers*

kumarshantanu17:11:18

Vase provides some reader literals, which is like a DSL in this case — you need to lookup Vase documentation for details on that DSL

kumarshantanu17:11:01

Inside the reader literals, the control may not be exactly like the usual Clojure code because the reader extension decides how to read and interpret that

amarjeet17:11:04

yes, Vase has docs on action literals

amarjeet17:11:48

i think i have to study 1-2 docs, I am looking at them n ow