reitit/examples/ring-example/src/example/schema.clj
2018-02-11 21:38:15 +02:00

18 lines
815 B
Clojure

(ns example.schema
(:require [schema.core :as s]
[reitit.coercion.schema]))
(def routes
["/schema" {:coercion reitit.coercion.schema/coercion}
["/plus" {:name ::plus
:responses {200 {:body {:total s/Int}}}
:get {:summary "plus with query-params"
:parameters {:query {:x s/Int, :y s/Int}}
:handler (fn [{{{:keys [x y]} :query} :parameters}]
{:status 200
:body {:total (+ x y)}})}
:post {:summary "plus with body-params"
:parameters {:body {:x s/Int, :y s/Int}}
:handler (fn [{{{:keys [x y]} :body} :parameters}]
{:status 200
:body {:total (+ x y)}})}}]])