DenoDDeno
Powered by
robtfmR
Denoβ€’2y agoβ€’
5 replies
robtfm

intercept an op rust-side and call the original fn

Hi, i'm using
deno_core
deno_core
and some exts embedded in a desktop application, and am trying to replace an existing op with my own version in which i do some additional checks before calling to the original op's function. i can replace the op using
Extension::middleware_fn
Extension::middleware_fn
, but i can't see a way to access the original op's function.

the simplest way i can think to do this would be to modify the op2 macro to expose the raw function. am i missing something simpler?

for context, i want to modify
op_ws_create
op_ws_create
from
deno_websocket
deno_websocket
to do a (potentially asynchronous) permission check, and add some default headers. i don't want to do it javascript-side because i worry that would be exploitable, but maybe it can be done safely (my js knowledge is far below my rust knowledge). i can't use the built-in
WebSocketPermissions
WebSocketPermissions
trait as it is a synchronous function (i guess i could modify it to be async instead).
Deno banner
DenoJoin
Chat about Deno, a modern runtime for JavaScript and TypeScript.
20,944Members
Resources
Recent Announcements

Similar Threads

Was this page helpful?

Similar Threads

How do you define an op in rust to return a string?
A Frickn ChicknAA Frickn Chickn / help
2y ago
block js with #[op2] fn without blocking rust thread
JacobZwangJJacobZwang / help
2y ago
Call Rust function from Deno API
thomasmandorferTthomasmandorfer / help
2y ago
Pass JS function to an Op that can be called after the Op ends
ExidexEExidex / help
17mo ago