mirror of
https://github.com/metosin/reitit.git
synced 2025-12-17 00:11:11 +00:00
Ensure that #145 works
This commit is contained in:
parent
34827ccf1c
commit
ec8727394d
2 changed files with 16 additions and 1 deletions
|
|
@ -54,3 +54,17 @@
|
|||
(is (= nil (coercion/coerce! m))))
|
||||
(let [m (r/match-by-path r "/none/kikka/abba")]
|
||||
(is (= nil (coercion/coerce! m))))))))
|
||||
|
||||
(defn match-by-path-and-coerce! [router path]
|
||||
(if-let [match (r/match-by-path router path)]
|
||||
(assoc match :parameters (coercion/coerce! match))))
|
||||
|
||||
(deftest data-spec-example-test
|
||||
(let [router (r/router
|
||||
["/:company/users/:user-id" {:name ::user-view
|
||||
:coercion reitit.coercion.spec/coercion
|
||||
:parameters {:path {:company string?
|
||||
:user-id int?}}}]
|
||||
{:compile coercion/compile-request-coercers})]
|
||||
(is (= {:path {:user-id 123, :company "metosin"}}
|
||||
(:parameters (match-by-path-and-coerce! router "/metosin/users/123"))))))
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
(ns reitit.ring-coercion-test
|
||||
(:require [clojure.test :refer [deftest testing is]]
|
||||
[schema.core :as s]
|
||||
[spec-tools.data-spec :as ds]
|
||||
[reitit.ring :as ring]
|
||||
[reitit.ring.coercion :as rrc]
|
||||
[reitit.coercion.spec :as spec]
|
||||
|
|
@ -48,7 +49,7 @@
|
|||
(ring/router
|
||||
["/api"
|
||||
["/plus/:e"
|
||||
{:get {:parameters {:query {:a int?}
|
||||
{:get {:parameters {:query {(ds/opt :a) int?}
|
||||
:body {:b int?}
|
||||
:form {:c int?}
|
||||
:header {:d int?}
|
||||
|
|
|
|||
Loading…
Reference in a new issue