reitit/examples/just-coercion-with-ring/src/example/dspec.clj

16 lines
442 B
Clojure
Raw Normal View History

2017-12-03 15:43:57 +00:00
(ns example.dspec
(:require [reitit.ring.coercion :as coercion]
[reitit.ring.coercion.spec :as spec-coercion]
[example.server :as server]))
(defn handler [{{{:keys [x y]} :query} :parameters}]
{:status 200
:body {:result (+ x y)
:source :data-spec}})
(def app
(-> #'handler
(server/wrap-coercion
{:parameters {:query {:x int?, :y int?}}
:coercion spec-coercion/coercion})))