Created
November 1, 2016 14:19
-
-
Save mishok13/eff5dc7defaac5f44a52a9b6632453aa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(set-env! | |
:source-paths #{"src"} | |
:dependencies | |
'[[yada "1.1.39" :exclusions [aleph manifold ring-swagger prismatic/schema]] | |
[aleph "0.4.2-alpha8"] | |
[manifold "0.1.6-alpha3"] | |
[metosin/ring-swagger "0.22.12"] | |
[prismatic/schema "1.1.3"]]) | |
(task-options! | |
aot {:namespace #{'reproducer}} | |
jar {:main 'reproducer}) | |
(require '[reproducer :refer [go!]]) | |
(defn- run-system | |
[& args] | |
(go!) | |
identity) | |
(deftask run | |
[] | |
(with-pass-thru _ | |
(go!))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns reproducer | |
(:require [bidi.bidi :refer [tag]] | |
[bidi.verbose :as bv] | |
[ring.swagger.schema :as rss] | |
[schema.core :as s] | |
[yada.yada :as yada])) | |
(defn handler | |
[ctx] | |
(prn (get-in ctx [:parameters :query])) | |
"") | |
(defn- foo-resource | |
[] | |
(bv/leaf | |
"/foo" | |
(yada/resource {:id :reproducer/event | |
:description "Bogus endpoint" | |
:responses {400 {:produces #{"text/plain"} | |
:description "Missing parameters or bad types" | |
:response (fn [ctx] "")} | |
200 {:produces #{"text/plain"} | |
:description "Event recorded" | |
:response (fn [ctx] "")}} | |
:methods | |
{:get | |
{:produces #{"application/json;q=0.9" | |
"application/edn;q=0.1"} | |
:consumes #{"*"} | |
:parameters {:query {:b (rss/field s/Str {:description "Bogus"})}} | |
:response handler}} | |
:access-control {:allow-origin "*"}}))) | |
(def routes | |
(bv/branch | |
"" | |
(bv/leaf "" (-> (foo-resource) | |
(yada/swaggered {:info {:title "bogus" | |
:version "1.0" | |
:description "bogus"}}) | |
(tag :reproducer/routes))) | |
(bv/leaf true (yada/handler nil)))) | |
(defn go! | |
[] | |
(let [x (promise)] | |
(yada/listener routes {:port 3232}) | |
@x)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment