about summary refs log tree commit diff stats
path: root/src/io/about.nim
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2023-08-13 17:42:34 +0200
committerbptato <nincsnevem662@gmail.com>2023-08-13 17:54:05 +0200
commitd526deb99e44f2a8d1a9c3eea60676703dd64302 (patch)
treef63689ff7654d14ad9bca182a837b3155b2471a0 /src/io/about.nim
parentf92e30232252deb194596e7c298cc7fcf56517cb (diff)
downloadchawan-d526deb99e44f2a8d1a9c3eea60676703dd64302.tar.gz
Add mailcap, mime.types & misc refactorings
* add mailcap: works with copiousoutput, needsterminal, etc.
* add mime.types (only works with mailcap)
* refactor pipeBuffer
* remove "dispatcher"
* fix bug in directory display where baseurl would not be used
Diffstat (limited to 'src/io/about.nim')
-rw-r--r--src/io/about.nim29
1 files changed, 14 insertions, 15 deletions
diff --git a/src/io/about.nim b/src/io/about.nim
index 97e01133..737a291b 100644
--- a/src/io/about.nim
+++ b/src/io/about.nim
@@ -1,9 +1,9 @@
-import streams
 import tables
 
+import io/connecterror
 import io/headers
+import io/loaderhandle
 import io/request
-import ips/serialize
 import types/url
 
 const chawan = staticRead"res/chawan.html"
@@ -11,19 +11,18 @@ const HeaderTable = {
   "Content-Type": "text/html"
 }.toTable()
 
-proc loadAbout*(request: Request, ostream: Stream) =
+proc loadAbout*(handle: LoaderHandle, request: Request) =
+  template t(body: untyped) =
+    if not body:
+      return
   if request.url.pathname == "blank":
-    ostream.swrite(0)
-    ostream.swrite(200) # ok
-    let headers = newHeaders(HeaderTable)
-    ostream.swrite(headers)
+    t handle.sendResult(0)
+    t handle.sendStatus(200) # ok
+    t handle.sendHeaders(newHeaders(HeaderTable))
   elif request.url.pathname == "chawan":
-    ostream.swrite(0)
-    ostream.swrite(200) # ok
-    let headers = newHeaders(HeaderTable)
-    ostream.swrite(headers)
-    ostream.write(chawan)
+    t handle.sendResult(0)
+    t handle.sendStatus(200) # ok
+    t handle.sendHeaders(newHeaders(HeaderTable))
+    t handle.sendData(chawan)
   else:
-    ostream.swrite(-1)
-  ostream.flush()
-
+    t handle.sendResult(ERROR_ABOUT_PAGE_NOT_FOUND)