aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChloe Kudryavtsev <code@toast.bunkerlabs.net>2023-03-25 16:50:50 -0400
committerChloe Kudryavtsev <code@toast.bunkerlabs.net>2023-03-25 16:50:50 -0400
commitde0ef0e281da2305ba2a6c97365bbf4ed503faa5 (patch)
tree99ff8435158fbdbbb322627c30a29328fb7d5219
parentjanet: misc alignment (diff)
janet: also recognize jurl-mime in jurl/mime
-rw-r--r--jurl/mime.janet6
1 files changed, 4 insertions, 2 deletions
diff --git a/jurl/mime.janet b/jurl/mime.janet
index c901677..852e6d2 100644
--- a/jurl/mime.janet
+++ b/jurl/mime.janet
@@ -9,7 +9,9 @@
:headers headers
:encoder encoder}]
(match data
+ # easily differentiable api
(b (bytes? b)) (:data handle b)
+ (amime (= (type amime) :jurl-mime)) (:subparts handle amime)
# symmetric api, the above is a shortcut
[:bytes b] (:data handle b)
@@ -22,12 +24,12 @@
# for callback you must pass [size callback] since mime wants that
# it's the only thing that wants it, so a number in front is unambiguous
- ([sz cb] (number? sz)) (:data-cb handle sz cb)
+ ([sz cb] (and (number? sz) (function? cb))) (:data-cb handle sz cb)
# allow empty body
nil nil
- (error "mime data may only be bytes, [:bytes bytes], [:file filename], [:mime mime], or [size callback]"))
+ (error "mime data may only be bytes, jurl-mime, [:bytes bytes], [:file filename], [:mime jurl-mime], or [size callback]"))
(when name (:name handle name))
(when filename (:filename handle filename))