reitit/examples/ring-example/src/example/dspec.clj

18 lines
785 B
Clojure
Raw Normal View History

2017-12-03 15:43:40 +00:00
(ns example.dspec
2017-12-09 21:21:03 +00:00
(:require [reitit.coercion.spec :as spec-coercion]))
2017-12-03 15:43:40 +00:00
(def routes
2017-12-09 21:21:03 +00:00
["/dspec" {:coercion spec-coercion/coercion}
2017-12-03 15:43:40 +00:00
["/plus" {:name ::plus
:responses {200 {:schema {:total int?}}}
:get {:summary "plus with query-params"
:parameters {:query {:x int?, :y int?}}
:handler (fn [{{{:keys [x y]} :query} :parameters}]
{:status 200
:body {:total (+ x y)}})}
:post {:summary "plus with body-params"
:parameters {:body {:x int?, :y int?}}
:handler (fn [{{{:keys [x y]} :body} :parameters}]
{:status 200
:body {:total (+ x y)}})}}]])