robtfm
robtfm
DDeno
Created by robtfm on 6/21/2024 in #help
intercept an op rust-side and call the original fn
Hi, i'm using 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, 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 from 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 trait as it is a synchronous function (i guess i could modify it to be async instead).
6 replies