Fork me on GitHub
#yada
<
2017-08-08
>
delitescere06:08:23

Yep, well, POSIX sed is even suckier - there’s no -i option at all (so it’s explicit redirection and renaming)

dominicm07:08:27

it would be good to push a few standards up perhaps. ¯\(ツ)

borkdude10:08:09

Any recommendations on where to register a custom transit writer with yada? (for yoda time dates)

malcolmsparks11:08:30

Register a new media type?

borkdude11:08:57

where/how? I’m not sure. I was thinking overriding the defmethods

malcolmsparks11:08:31

Afk. But all media types are registered with defmethod. Git grep defmethod you should find some.

borkdude11:08:59

and have a nice vacation!

vinnyataide14:08:10

Hello I'm trying to understand the yada/bidi/ring relation, I'm getting a table with a :handler topkey which I think is the ring handler that goes through a ring-compatible server

vinnyataide14:08:36

I'm going through the transformations in this sequence: yada/resource -> bidi/match-route -> yada/handler

dominicm15:08:28

@vinnyataide

(ring req)  (ring req)          (yada ctx)
Aleph ----> Bidi ------> Yada Handler ------> Yada resource

dominicm15:08:19

bidi really doesn't touch the ring request or response at all

vinnyataide15:08:52

I created the handler based on the resource return so I could attach to the handler, but it looks like I had it flipped =P

vinnyataide15:08:42

oh yeah, my mistake the code looks like yours but the bidi method comes first

vinnyataide15:08:08

(defn handler [{:keys [uri]}]
  (println uri)
  (yada/handler (bidi/match-route route uri)))

vinnyataide15:08:36

the route returns a yada/resource like this

(def route ["/" {""  (layout main-page) ...
(defn layout [content]
  (yada/resource
   {:access-control
    {:realm "account"
     :scheme "basic"
     :verify (fn [ctx] (println ctx))}
    :methods
    {:get
...

dominicm15:08:51

(defn handler [{:keys [uri] :as req}]
  ((yada/handler (bidi/match-route route uri)) req))
Try this

dominicm15:08:10

(I have no idea how expensive the creation of a handler is)

dominicm15:08:35

It's also worth noting that if you pass a vector to yada/handler, it will create a bidi router for you & such.

vinnyataide15:08:29

so I don't need bidi/match-route right?

dominicm15:08:35

You can skip it, yep

dominicm16:08:00

If you haven't got a pre-existing project for this, it's a little easier to use edge https://github.com/juxt/edge Others have bootstrapped from it.

vinnyataide19:08:27

I don't get in this example what server is running... I'm trying to run aleph with the return of the yada/handler as the handler. but in this example there's a vhost usecase

vinnyataide19:08:16

@dominicm and that's essentially the issue, how my handler is being handled by aleph is not correctly working I assume

vinnyataide19:08:27

that's the system that I'm using from system.components

(defsystem dev-system
  [:db (new-datomic-db (env :db-uri))
   :web (component/using
         (new-web-server (read-string (env :http-port))
                         handler)
         [:db])])

vinnyataide19:08:08

(:require [system.core :refer [defsystem]]
            (system.components
             [aleph :refer [new-web-server]]
             [datomic :refer [new-datomic-db]])

dominicm19:08:39

Honestly, using yada/listener is way easier than configuring this yourself