about summary refs log tree commit diff stats
path: root/src/loader/about.nim
blob: 1bbe962596c7c02e2d8008c3709b943231479697 (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
27
28
import tables

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"
}.toTable()

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)