Skip to content

Commit 88c2182

Browse files
Properly dispatch to implementations
1 parent 7322257 commit 88c2182

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

libraries/common/io/requests.effekt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -477,19 +477,19 @@ namespace internal {
477477
extern pure def backend(): String =
478478
jsNode { "js-node" }
479479
jsWeb { "js-web" }
480+
481+
extern pure def ifNode[R]{ thnNode: => R }{ thnWeb: => R }: R =
482+
jsNode { thnNode() }
483+
jsWeb { thnWeb() }
480484
}
481485

482486
/// Make a HTTP(S) request on the backend-specific implementation,
483487
/// then pass the response to the second block parameter to process.
484488
///
485489
/// The Request body is buffered, the response is streaming (as far
486490
/// as the backend implementation allows).
487-
def request[R]{ body: => Unit / RequestBuilder }{ res: {ResponseReader} => R }: R / Exception[RequestError] = internal::backend() match {
488-
// TODO use a proper dispatch after #448 is resolved
489-
case "js-node" => jsNode::request{body}{res}
490-
case "js-web" => jsWeb::request{body}{res}
491-
case _ => <>
492-
}
491+
def request[R]{ body: => Unit / RequestBuilder }{ res: {ResponseReader} => R }: R / Exception[RequestError] =
492+
internal::ifNode{ jsNode::request{body}{res} }{ jsWeb::request{body}{res} }
493493

494494
// Simple API
495495
// ----------

0 commit comments

Comments
 (0)