Fork me on GitHub
#luminus
<
2018-04-18
>
yogthos01:04:40

@alexchalk17 yeah that part isn't obvious, the user comes from here:

(defmethod restructure-param :current-user
  [_ binding acc]
  (update-in acc [:letks] into [binding `(:identity ~'+compojure-api-request+)]))

yogthos01:04:51

compojure-api is injecting the user in the :current-user key, and it's a reverse binding where the user symbol gets populated with the value of the :current-user key

adc1703:04:00

So if I’ve understood, that method says ’when the metadata key is :current-user, bind its value’s symbol (`binding`) to (:identity ~'+compojure-api-request+)?

yogthos12:04:12

yeah so original data comes from the :identity key in the request, and it's injected into the :current-user key in the route declaration, and that key is mapped to the user symbol that you end up using in the route

adc1714:04:23

hmm, so how would it be different if :lets was used instead of :letks?

adc1716:04:53

Is user a key in (:identity ~'+compojure-api-request+) whose value we’re retrieving? i.e. would the result be different if we changed user to present-user? (As opposed to a let binding which would just assign all of (:identity ~'+compojure-api-request+) to whatever var we picked?) That’s my best guess at the difference?

yogthos12:04:46

The user is the symbol that ends up being used in the route declaration, you can call it present-user, or anything. Technically, this is just a convenience anyways, you could pull the identity directly from the request, e.g:

(GET "/myroute" request
   (let [user (:identity request_] ...))

adc1712:04:22

@U050CBXUZ in that case it doesn’t look like a keybinding at all, it’s just a regular let binding from what I can see. So do you know when [:lets] should be used instead of [:letks]?

yogthos12:04:02

it's mostly preference, and yeah it's just the funky syntax that particular macro uses where you're effectively binding in reverse going from key to the symbol

adc1713:04:44

I’m just trying to understand how your code would function differently if you’d used [:lets]?

adc1713:04:23

Normally I would go straight to the source-code, but in this case I found it super-complicated.

adc1713:04:56

Is it purely the ordering in which the bindings are done? I can’t find any other difference…

:lets, a vector of let bindings applied first before the actual body
:letks, a vector of letk bindings applied second before the actual body

cmal06:04:42

Hi, I am trying to add postgres into my luminus project. I used +postgres to generate my luminus project. Now I want to add the connection URL into my project so that I can access the postgres database. In the docs.md, I found

Create the database for your application.
* Update the connection URL in the `profiles.clj` file with your database name and login
but I cannot find the profiles.clj file in my project. I also found there is a :database-url in my app.config/env variable whose value is but I cannot find where this is defined. Can anyone help me out?

cmal07:04:31

But I am confusing why the :database-url key can not be loaded by (load-config) when setting in config.edn while other key-values works well.

cmal08:04:47

I found that. in dev-config.edn , this is not git version controlled, so cannot searched by ag.

yogthos12:04:52

@cmal yeah sorry, missed a spot in the docs when I switched from profiles.clj to dev-config.edn