Skip to content

Commit 8da18f5

Browse files
Prepare dispatch for more cases
1 parent 88c2182 commit 8da18f5

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

libraries/common/io/requests.effekt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -478,9 +478,13 @@ namespace internal {
478478
jsNode { "js-node" }
479479
jsWeb { "js-web" }
480480

481-
extern pure def ifNode[R]{ thnNode: => R }{ thnWeb: => R }: R =
481+
extern pure def ifJSNode[R]{ thnNode: => R }{ els: => R }: R =
482482
jsNode { thnNode() }
483+
default { els() }
484+
extern pure def ifJSWeb[R]{ thnWeb: => R }{ els: => R }: R =
483485
jsWeb { thnWeb() }
486+
default { els() }
487+
extern pure def unsupported[R](): R =
484488
}
485489

486490
/// Make a HTTP(S) request on the backend-specific implementation,
@@ -489,7 +493,9 @@ namespace internal {
489493
/// The Request body is buffered, the response is streaming (as far
490494
/// as the backend implementation allows).
491495
def request[R]{ body: => Unit / RequestBuilder }{ res: {ResponseReader} => R }: R / Exception[RequestError] =
492-
internal::ifNode{ jsNode::request{body}{res} }{ jsWeb::request{body}{res} }
496+
with internal::ifJSNode{ jsNode::request{body}{res} }
497+
with internal::ifJSWeb{ jsWeb::request{body}{res} }
498+
internal::unsupported[R]()
493499

494500
// Simple API
495501
// ----------

0 commit comments

Comments
 (0)