about summary refs log tree commit diff stats
path: root/src/html/env.nim
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2023-04-30 12:19:24 +0200
committerbptato <nincsnevem662@gmail.com>2023-04-30 12:19:24 +0200
commita02c408f933aea6f405ed3c64ab151b01b33ae9e (patch)
tree4946f6b13da782a92a1ecc0f03402abacf2614b3 /src/html/env.nim
parent05b64a1d8fa95381d756231f665c0b8c79787b67 (diff)
downloadchawan-a02c408f933aea6f405ed3c64ab151b01b33ae9e.tar.gz
WIP fetch
Diffstat (limited to 'src/html/env.nim')
-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)),