diff options
author | Matt Mastracci <matthew@mastracci.com> | 2023-03-17 12:22:15 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-17 18:22:15 +0000 |
commit | e55b448730160a6e4df9815a268d4049ac89deab (patch) | |
tree | 35d80fd60f2f1d1d06903caff256484a7d703d76 /runtime/ops/http.rs | |
parent | 0bc6bf5d33b8198253954d7f04558270de45c925 (diff) |
feat(core) deno_core::extension! macro to simplify extension registration (#18210)
This implements two macros to simplify extension registration and centralize a lot of the boilerplate as a base for future improvements:
* `deno_core::ops!` registers a block of `#[op]`s, optionally with type
parameters, useful for places where we share lists of ops
* `deno_core::extension!` is used to register an extension, and creates
two methods that can be used at runtime/snapshot generation time:
`init_ops` and `init_ops_and_esm`.
---------
Co-authored-by: Bartek IwaĆczuk <biwanczuk@gmail.com>
Diffstat (limited to 'runtime/ops/http.rs')
-rw-r--r-- | runtime/ops/http.rs | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/runtime/ops/http.rs b/runtime/ops/http.rs index 51562589e..b9899b4e3 100644 --- a/runtime/ops/http.rs +++ b/runtime/ops/http.rs @@ -8,7 +8,6 @@ use deno_core::error::bad_resource_id; use deno_core::error::custom_error; use deno_core::error::AnyError; use deno_core::op; -use deno_core::Extension; use deno_core::OpState; use deno_core::RcRef; use deno_core::ResourceId; @@ -28,15 +27,10 @@ use deno_net::io::UnixStreamResource; #[cfg(unix)] use tokio::net::UnixStream; -pub fn init() -> Extension { - Extension::builder("deno_http_runtime") - .ops(vec![ - op_http_start::decl(), - op_http_upgrade::decl(), - op_flash_upgrade_http::decl(), - ]) - .build() -} +deno_core::extension!( + deno_http_runtime, + ops = [op_http_start, op_http_upgrade, op_flash_upgrade_http], +); #[op] fn op_http_start( |