about summary refs log tree commit diff stats
path: root/src/io/request.nim
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2023-06-19 18:13:10 +0200
committerbptato <nincsnevem662@gmail.com>2023-06-19 18:15:09 +0200
commit17097052794aef56bbc55327d3e6c84ae1c67378 (patch)
tree13b81e1105c07c69d7a8d1e7367a698f41663a01 /src/io/request.nim
parente372bdaa0344b23c91aefa4da44c578fbf8f49e2 (diff)
downloadchawan-17097052794aef56bbc55327d3e6c84ae1c67378.tar.gz
Rework JS exception system
Now we use Result for passing exceptions to JS. As a result, we can
finally get rid of the .jserr pragma.
Diffstat (limited to 'src/io/request.nim')
-rw-r--r--src/io/request.nim16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/io/request.nim b/src/io/request.nim
index 11e16718..8bc2bfc8 100644
--- a/src/io/request.nim
+++ b/src/io/request.nim
@@ -66,8 +66,8 @@ type
     httpmethod*: HttpMethod
     url*: Url
     headers* {.jsget.}: Headers
-    body*: Option[string]
-    multipart*: Option[FormData]
+    body*: Opt[string]
+    multipart*: Opt[FormData]
     referer*: URL
     mode* {.jsget.}: RequestMode
     destination* {.jsget.}: RequestDestination
@@ -185,7 +185,7 @@ func newHeaders*(table: Table[string, string]): Headers =
       result.table[k] = @[v]
 
 func newRequest*(url: URL, httpmethod = HTTP_GET, headers = newHeaders(),
-    body = none(string), multipart = none(FormData), mode = RequestMode.NO_CORS,
+    body = opt(string), multipart = opt(FormData), mode = RequestMode.NO_CORS,
     credentialsMode = CredentialsMode.SAME_ORIGIN,
     destination = RequestDestination.NO_DESTINATION, proxy: URL = nil): Request =
   return Request(
@@ -201,8 +201,8 @@ func newRequest*(url: URL, httpmethod = HTTP_GET, headers = newHeaders(),
   )
 
 func newRequest*(url: URL, httpmethod = HTTP_GET,
-    headers: seq[(string, string)] = @[], body = none(string),
-    multipart = none(FormData), mode = RequestMode.NO_CORS, proxy: URL = nil):
+    headers: seq[(string, string)] = @[], body = opt(string),
+    multipart = opt(FormData), mode = RequestMode.NO_CORS, proxy: URL = nil):
     Request =
   let hl = newHeaders()
   for pair in headers:
@@ -234,12 +234,12 @@ func newRequest*(ctx: JSContext, resource: string,
   let url = x.get
   let fallbackMode = some(RequestMode.CORS) #TODO none if resource is request
   var httpMethod = HTTP_GET
-  var body = none(string)
+  var body = opt(string)
   var credentials = CredentialsMode.SAME_ORIGIN
   var mode = fallbackMode.get(RequestMode.NO_CORS)
   let hl = newHeaders()
-  var proxyUrl = none(URL)
-  var multipart = none(FormData)
+  var proxyUrl: Opt[URL]
+  var multipart: Opt[FormData]
   #TODO fallback mode, origin, window, request mode, ...
   if init.isSome:
     let init = init.get