-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.golo
48 lines (37 loc) · 1011 Bytes
/
main.golo
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
42
43
44
45
46
47
48
module try_vertx
import vert.x.helpers
import web.extensions
function main = |args| {
let server = createHttpServer()
let router = getRouter()
# with augmentations
router: get("/yo", |context| ->
context: response(): json(DynamicObject(): message("yo!"))
)
router: get("/yo/:id", |context| ->
context: response(): json(
DynamicObject()
: message("yo!")
: id(context: request(): param("id"))
)
)
# without augmentation
router: get("/hello"): handler(|context| {
let response = context: response()
response: putHeader("content-type", "text/plain")
response: end("Hello World from Golo.x-Web!")
})
router: get("/hi"): handler(|context| {
let response = context: response()
response: putHeader("content-type", "application/json")
response: end(JSON.stringify(map[
["message","Hello World from Golo.x-Web!"]
]))
})
startHttpServer(
server=server,
router=router,
port=9090,
staticPath="/*"
)
}