Fork me on GitHub
#yada
<
2018-08-23
>
agigao13:08:59

Hi there, I’ve been playing with yada lately and decided to go “simple” route, build on my own instead of using edge. So, right now have: - db connection(postgresql) - resource defined - route created and trying to fire-up aleph server, which I’m having tough time to achieve.

agigao13:08:15

(ns va-api.core
  (:require [va-api.db :refer [db]]
            [va-api.sql :as sql]
            [yada.yada :as yada]
            [aleph.http :as http]
            [clojure.pprint :as pprint])
  (:gen-class))

(def index-resource
  (yada/resource
    {:produces {:media-type "text/plain"}
     :methods {:get
               {:response (sql/get-persons db)}
               }}))

(defn routes [_]
  ["/" (yada/handler index-resource)])

(http/start-server routes {:port 8080})

dominicm15:08:09

What's going wrong?

dominicm15:08:02

Oh, you need to call (yada/handler (routes)) I think.

dominicm15:08:09

When you start the server

agigao21:08:19

Well, I tried and received a yada page with methods, interceptor-chain etc. But (http/start-server (yada/handler index-resource) {:port 8080}) works fine. Another but: how can I bind multiple routes to a single yada handler?