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

16 lines
457 B
Clojure
Raw Normal View History

2017-12-03 15:43:57 +00:00
(ns example.schema
2017-12-09 20:49:32 +00:00
(:require [reitit.ring.coercion-middleware :as coercion]
2017-12-03 15:43:57 +00:00
[reitit.ring.coercion.schema :as schema-coercion]
[example.server :as server]))
(defn handler [{{{:keys [x y]} :query} :parameters}]
{:status 200
:body {:result (+ x y)
:source :schema}})
(def app
(-> #'handler
(server/wrap-coercion
{:parameters {:query {:x Long, :y Long}}
:coercion schema-coercion/coercion})))