mirror of
https://github.com/metosin/reitit.git
synced 2025-12-18 08:51:12 +00:00
Cleanup examples
This commit is contained in:
parent
ae75021aac
commit
509697dc55
6 changed files with 15 additions and 13 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
(defproject just-coercion-with-ring "0.1.0-SNAPSHOT"
|
(defproject just-coercion-with-ring "0.1.0-SNAPSHOT"
|
||||||
:description "Reitit coercion with vanilla ring"
|
:description "Reitit coercion with vanilla ring"
|
||||||
:dependencies [[org.clojure/clojure "1.9.0-RC2"]
|
:dependencies [[org.clojure/clojure "1.9.0"]
|
||||||
[ring "1.6.3"]
|
[ring "1.6.3"]
|
||||||
[metosin/muuntaja "0.4.1"]
|
[metosin/muuntaja "0.4.1"]
|
||||||
[metosin/reitit "0.1.0-SNAPSHOT"]])
|
[metosin/reitit "0.1.0-SNAPSHOT"]])
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
(ns example.server
|
(ns example.server
|
||||||
(:require [ring.adapter.jetty :as jetty]
|
(:require [ring.adapter.jetty :as jetty]
|
||||||
|
[muuntaja.middleware]
|
||||||
|
[ring.middleware.params]
|
||||||
[reitit.middleware :as middleware]
|
[reitit.middleware :as middleware]
|
||||||
[reitit.ring.coercion :as rrc]))
|
[reitit.ring.coercion :as rrc]))
|
||||||
|
|
||||||
|
|
@ -10,9 +12,9 @@
|
||||||
;; to be set with :extract-request-format and extract-response-format
|
;; to be set with :extract-request-format and extract-response-format
|
||||||
(defn wrap-coercion [handler resource]
|
(defn wrap-coercion [handler resource]
|
||||||
(middleware/chain
|
(middleware/chain
|
||||||
[rrc/coerce-request-middleware
|
[rrc/coerce-exceptions-middleware
|
||||||
rrc/coerce-response-middleware
|
rrc/coerce-request-middleware
|
||||||
rrc/coerce-exceptions-middleware]
|
rrc/coerce-response-middleware]
|
||||||
handler
|
handler
|
||||||
resource))
|
resource))
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
(defproject just-coercion-with-ring "0.1.0-SNAPSHOT"
|
(defproject ring-example "0.1.0-SNAPSHOT"
|
||||||
:description "Reitit coercion with vanilla ring"
|
:description "Reitit Ring App"
|
||||||
:dependencies [[org.clojure/clojure "1.9.0-RC2"]
|
:dependencies [[org.clojure/clojure "1.9.0"]
|
||||||
[ring "1.6.3"]
|
[ring "1.6.3"]
|
||||||
[metosin/muuntaja "0.4.1"]
|
[metosin/muuntaja "0.4.1"]
|
||||||
[metosin/reitit "0.1.0-SNAPSHOT"]])
|
[metosin/reitit "0.1.0-SNAPSHOT"]])
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
(ns example.dspec
|
(ns example.dspec
|
||||||
(:require [reitit.coercion.spec :as spec-coercion]))
|
(:require [reitit.coercion.spec]))
|
||||||
|
|
||||||
(def routes
|
(def routes
|
||||||
["/dspec" {:coercion spec-coercion/coercion}
|
["/dspec" {:coercion reitit.coercion.spec/coercion}
|
||||||
["/plus" {:name ::plus
|
["/plus" {:name ::plus
|
||||||
:responses {200 {:schema {:total int?}}}
|
:responses {200 {:schema {:total int?}}}
|
||||||
:get {:summary "plus with query-params"
|
:get {:summary "plus with query-params"
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
(ns example.schema
|
(ns example.schema
|
||||||
(:require [schema.core :as s]
|
(:require [schema.core :as s]
|
||||||
[reitit.coercion.schema :as schema-coercion]))
|
[reitit.coercion.schema]))
|
||||||
|
|
||||||
(def routes
|
(def routes
|
||||||
["/schema" {:coercion schema-coercion/coercion}
|
["/schema" {:coercion reitit.coercion.schema/coercion}
|
||||||
["/plus" {:name ::plus
|
["/plus" {:name ::plus
|
||||||
:responses {200 {:schema {:total s/Int}}}
|
:responses {200 {:schema {:total s/Int}}}
|
||||||
:get {:summary "plus with query-params"
|
:get {:summary "plus with query-params"
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
(ns example.spec
|
(ns example.spec
|
||||||
(:require [clojure.spec.alpha :as s]
|
(:require [clojure.spec.alpha :as s]
|
||||||
[spec-tools.spec :as spec]
|
[spec-tools.spec :as spec]
|
||||||
[reitit.coercion.spec :as spec-coercion]))
|
[reitit.coercion.spec]))
|
||||||
|
|
||||||
;; wrap into Spec Records to enable runtime conforming
|
;; wrap into Spec Records to enable runtime conforming
|
||||||
(s/def ::x spec/int?)
|
(s/def ::x spec/int?)
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
(s/def ::total spec/int?)
|
(s/def ::total spec/int?)
|
||||||
|
|
||||||
(def routes
|
(def routes
|
||||||
["/spec" {:coercion spec-coercion/coercion}
|
["/spec" {:coercion reitit.coercion.spec/coercion}
|
||||||
["/plus" {:name ::plus
|
["/plus" {:name ::plus
|
||||||
:responses {200 {:schema (s/keys :req-un [::total])}}
|
:responses {200 {:schema (s/keys :req-un [::total])}}
|
||||||
:get {:summary "plus with query-params"
|
:get {:summary "plus with query-params"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue