Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: ce073ae420
Fetching contributors…

Cannot retrieve contributors at this time

29 lines (24 sloc) 1.268 kb
(ns clj-spore
(:require [cheshire.core :as json]
[clj-spore.generator :as gen]
[clj-spore.middleware :as mid]))
(defn load-method
[desc spec name & {:keys [middlewares overload options] :or {middlewares [] overload {} options {}}}]
(let [merged-spec (merge spec overload)]
(gen/generate-spore-method desc spec name middlewares options)))
(defn load-spec
[spec & {:keys [middlewares overload options] :or {middlewares [] overload {} options {}}}]
(let
[methods (spec :methods)
api-desc (merge (dissoc spec :methods) overload)]
(reduce (fn [coll [m-name m-spec]] (assoc coll (keyword m-name) (load-method api-desc m-spec m-name :middlewares middlewares :overload overload :options options)))
{}
methods)))
(defn load-spec-from-json
[json & {:keys [middlewares overload options] :or {middlewares [] overload {} options {}}}]
(let
[spec (json/parse-string json true)]
(load-spec spec :middlewares middlewares :overload overload :options options)))
(defn load-spec-from-file
[filepath & {:keys [middlewares overload options] :or {middlewares [] overload {} options {}}}]
(load-spec-from-json (slurp filepath) :middlewares middlewares :overload overload :options options))
Jump to Line
Something went wrong with that request. Please try again.