-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathapp.nim
More file actions
28 lines (21 loc) · 768 Bytes
/
Copy pathapp.nim
File metadata and controls
28 lines (21 loc) · 768 Bytes
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
import prologue
# Create default settings
let settings = newSettings()
# Create instance
var app = newApp(settings = settings)
# Create routes
app.addRoute("/add", proc(ctx: Context) {.async.} =
ctx.response.addHeader("My-Custom-Header", "1234")
resp "Open Developer Console and check for the custom header"
)
app.addRoute("/set", proc(ctx: Context) {.async.} =
ctx.response.addHeader("My-Custom-Header", "1234")
ctx.response.setHeader("My-Custom-Header", "5678")
resp "Open Developer Console and check for the custom header"
)
app.addRoute("/json", proc(ctx: Context) {.async.} =
ctx.response.addHeader("My-Custom-Header", "1234")
resp jsonResponse(%*"""{"key":"value"}""", headers = ctx.response.headers)
)
# Run instance
app.run()