about summary refs log tree commit diff stats
path: root/adapter
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2023-12-12 10:38:42 +0100
committerbptato <nincsnevem662@gmail.com>2023-12-12 19:37:14 +0100
commit4eb57c2b88325d3963c6671a6f27bd08fc07cb59 (patch)
tree06bec584dcaf017d94e570e6cffb394b75aca338 /adapter
parentf779f672e6aa28efe03733226465c73c1a7490ad (diff)
downloadchawan-4eb57c2b88325d3963c6671a6f27bd08fc07cb59.tar.gz
local CGI: add mapped URI env vars; move about: to adapters
* Add MAPPED_URI_* as environment variables when a request is coming
  from urimethodmap

It costs us compatibility with w3m, but it seems to be a massive
improvement over smuggling in the URL as a query string and then
writing an ad-hoc parser for every single urimethodmap script.

The variables are set for every urimethodmap request, to avoid
accidental leaking of global environment variables.

* Move about: to adapters (an obvious improvement over the previous
  solution)
Diffstat (limited to 'adapter')
-rw-r--r--adapter/about/about.nim14
1 files changed, 14 insertions, 0 deletions
diff --git a/adapter/about/about.nim b/adapter/about/about.nim
new file mode 100644
index 00000000..860294f3
--- /dev/null
+++ b/adapter/about/about.nim
@@ -0,0 +1,14 @@
+import std/envvars
+
+const chawan = staticRead"res/chawan.html"
+const license = staticRead"res/license.html"
+
+proc main() =
+  stdout.write("Content-Type: text/html\n\n")
+  case getEnv("MAPPED_URI_PATH")
+  of "blank": stdout.write("")
+  of "chawan": stdout.write(chawan)
+  of "license": stdout.write(license)
+  else: stdout.write("Error: about page not found")
+
+main()