Fork me on GitHub
#yada
<
2016-08-25
>
frozenlock00:08:25

I'm a little confused about the role of vhosts. I added one to be able to test an api in which I'm using yada/uri-for. It works... but when I try in a live application, I get the same error as before I added the vhosts for my tests.

frozenlock00:08:17

Is yada/uri-for the proper way to refer to other api endpoints?

aengelberg05:08:19

Is there a way to serve a text/event-stream in a yada resource that uses a custom data encoder besides EDN? I'm running into limitations with the EDN serializer and want to use transit with custom tags.

dominicm09:08:46

@frozenlock: It is, yep. Not sure why you'd see issues in prod. What's different about the environments?

frozenlock09:08:43

dominicm : one is using vhosts... the live application doesn't 😛

dominicm09:08:43

@frozenlock: That'll be why uri-for doesn't exist then!

frozenlock10:08:02

Hmm... but with vhosts (which I assume is for virtual hosts) I have to give a host, no?

frozenlock10:08:44

Before trying to use :uri-for I was manually fetching all the data in the request to reconstruct the entire URI.

frozenlock10:08:54

(defn make-link
  "Given a request context, return the full URL (with scheme and host)
  for the current request, or for a given path."
  ([ctx] (make-link ctx (:uri (:request ctx))))
  ([ctx path]
   (str (name (get-in ctx [:request :scheme]))
        "://"
        (or (get-in ctx [:request :headers "host"]) ;; for tests
            (get-in ctx [:request :server-name]))
        path)))