bangalore-clj

https://www.meetup.com/Bangalore-Clojure-User-Group/
amarjeet 2017-11-06T09:19:45.000204Z

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

Shantanu Kumar 2017-11-06T16:48:38.000277Z

@amarjeet Can you give an example?

amarjeet 2017-11-06T17:15:06.000310Z

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?

amarjeet 2017-11-06T17:15:27.000131Z

@kumarshantanu

amarjeet 2017-11-06T17:16:02.000152Z

*api routes, which are in the EDN file

Shantanu Kumar 2017-11-06T17:20:09.000701Z

@amarjeet Are you talking about this file? https://github.com/amarjeet000/vase-demo/blob/master/resources/vase-demo_service.edn

amarjeet 2017-11-06T17:20:22.000373Z

yes

Shantanu Kumar 2017-11-06T17:21:18.000251Z

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?

amarjeet 2017-11-06T17:23:03.000626Z

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.

Shantanu Kumar 2017-11-06T17:28:06.000008Z

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

Shantanu Kumar 2017-11-06T17:28:33.000198Z

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

Shantanu Kumar 2017-11-06T17:29:18.000051Z

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

Shantanu Kumar 2017-11-06T17:31:01.000351Z

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

amarjeet 2017-11-06T17:32:04.000513Z

yes, Vase has docs on action literals

amarjeet 2017-11-06T17:33:48.000654Z

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