about summary refs log tree commit diff stats
path: root/src/loader/about.nim
blob: f2ac6d74a3d2b77ee757aaf00de1c537b367d8a7 (plain) (blame)
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
import loader/connecterror
import loader/headers
import loader/loaderhandle
import loader/request
import types/url

const chawan = staticRead"res/chawan.html"
const HeaderTable = {
  "Content-Type": "text/html"
}

proc loadAbout*(handle: LoaderHandle, request: Request) =
  template t(body: untyped) =
    if not body:
      return
  if request.url.pathname == "blank":
    t handle.sendResult(0)
    t handle.sendStatus(200) # ok
    t handle.sendHeaders(newHeaders(HeaderTable))
  elif request.url.pathname == "chawan":
    t handle.sendResult(0)
    t handle.sendStatus(200) # ok
    t handle.sendHeaders(newHeaders(HeaderTable))
    t handle.sendData(chawan)
  else:
    t handle.sendResult(ERROR_ABOUT_PAGE_NOT_FOUND)