From 2e74f164b6dcf0ecbf8dd38fba9fae550d784bd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Sun, 13 Dec 2020 19:45:53 +0100 Subject: refactor: deno_runtime crate (#8640) This commit moves Deno JS runtime, ops, permissions and inspector implementation to new "deno_runtime" crate located in "runtime/" directory. Details in "runtime/README.md". Co-authored-by: Ryan Dahl --- runtime/ops/fetch.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 runtime/ops/fetch.rs (limited to 'runtime/ops/fetch.rs') diff --git a/runtime/ops/fetch.rs b/runtime/ops/fetch.rs new file mode 100644 index 000000000..0ef99f73d --- /dev/null +++ b/runtime/ops/fetch.rs @@ -0,0 +1,25 @@ +// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. +use crate::http_util; +use crate::permissions::Permissions; +use deno_fetch::reqwest; + +pub fn init( + rt: &mut deno_core::JsRuntime, + user_agent: String, + maybe_ca_file: Option<&str>, +) { + { + let op_state = rt.op_state(); + let mut state = op_state.borrow_mut(); + state.put::({ + http_util::create_http_client(user_agent, maybe_ca_file).unwrap() + }); + } + super::reg_json_async(rt, "op_fetch", deno_fetch::op_fetch::); + super::reg_json_async(rt, "op_fetch_read", deno_fetch::op_fetch_read); + super::reg_json_sync( + rt, + "op_create_http_client", + deno_fetch::op_create_http_client::, + ); +} -- cgit v1.2.3