Skip to content

Commit 374cd67

Browse files
committed
yada delay depends of query param
1 parent e0e2144 commit 374cd67

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

yada-app/src/yada_app/routes.clj

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,26 @@
11
(ns yada-app.routes
22
(:require [yada.yada :as yada]
3+
[schema.core :as s]
34
[manifold.deferred :as d]))
45

56

67

7-
(defn hello-handler [ctx]
8-
(let [result (d/future
9-
(Thread/sleep 1000)
8+
(defn hello-response [ctx]
9+
(let [delay (get-in ctx [:parameters :query :delay])
10+
result (d/future
11+
(Thread/sleep delay)
1012
"hello world")]
1113
result))
1214

15+
(def hello-resource
16+
(yada/resource
17+
{:methods {:get
18+
{:parameters {:query {:delay s/Int}}
19+
:produces {:media-type "text/plain"}
20+
:response hello-response}}}))
21+
1322
(defn routes [base]
1423
[base
1524
[
16-
["" (yada/as-resource hello-handler)]
25+
["" hello-resource]
1726
[true (yada/as-resource nil)]]])

0 commit comments

Comments
 (0)