about summary refs log tree commit diff stats
path: root/src/html
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2023-04-30 18:59:19 +0200
committerbptato <nincsnevem662@gmail.com>2023-04-30 18:59:19 +0200
commit5db380ff789db24c6c48e2c513d9ca5ac7a606b3 (patch)
tree9296e1b88d48bf767df49cfbf08c43181da24b44 /src/html
parentc235e638788b43ca752179341e429f4d7e090870 (diff)
parenta02c408f933aea6f405ed3c64ab151b01b33ae9e (diff)
downloadchawan-5db380ff789db24c6c48e2c513d9ca5ac7a606b3.tar.gz
Merge branch 'wip_fetch'
Diffstat (limited to 'src/html')
-rw-r--r--src/html/env.nim6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/html/env.nim b/src/html/env.nim
index 7f270e58..58bad005 100644
--- a/src/html/env.nim
+++ b/src/html/env.nim
@@ -3,6 +3,8 @@ import streams
 import html/dom
 import html/htmlparser
 import io/loader
+import io/promise
+import io/request
 import js/javascript
 import types/url
 
@@ -51,6 +53,10 @@ proc addNavigatorModule(ctx: JSContext) =
   ctx.registerType(PluginArray)
   ctx.registerType(MimeTypeArray)
 
+proc fetch(window: Window, req: Request): Promise[Response] {.jsfunc.} =
+  if window.loader.isSome:
+    return window.loader.get.fetch(req)
+
 proc newWindow*(scripting: bool, loader = none(FileLoader)): Window =
   result = Window(
     console: console(err: newFileStream(stderr)),