We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e0e2144 commit 374cd67Copy full SHA for 374cd67
yada-app/src/yada_app/routes.clj
@@ -1,17 +1,26 @@
1
(ns yada-app.routes
2
(:require [yada.yada :as yada]
3
+ [schema.core :as s]
4
[manifold.deferred :as d]))
5
6
7
-(defn hello-handler [ctx]
8
- (let [result (d/future
9
- (Thread/sleep 1000)
+(defn hello-response [ctx]
+ (let [delay (get-in ctx [:parameters :query :delay])
10
+ result (d/future
11
+ (Thread/sleep delay)
12
"hello world")]
13
result))
14
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
+
22
(defn routes [base]
23
[base
24
[
- ["" (yada/as-resource hello-handler)]
25
+ ["" hello-resource]
26
[true (yada/as-resource nil)]]])
0 commit comments