-
Notifications
You must be signed in to change notification settings - Fork 0
/
Ratpack.groovy
41 lines (39 loc) · 1.11 KB
/
Ratpack.groovy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import static ratpack.groovy.Groovy.ratpack
ratpack {
handlers {
handler("subscriptions") {
byMethod {
get {
def cid = request.queryParams['cid']
if (cid) {
render "Got CID ${cid}"
} else {
response.status 422
response.send("application/json", /{"error": "Must set cid"}/)
}
}
post {
//TODO create a subscription
render "POST new subscription"
}
}
}
handler("subscriptions/:id") {
def id = pathTokens['id']
if (!id) {
response.status 422
response.send()
}
byMethod {
get {
//TODO display subscription
render "GET $id"
}
put {
//TODO update subscription
render "PUT $id"
}
}
}
}
}