summaryrefslogtreecommitdiffhomepage
path: root/src/wasm/nxt_rt_wasmtime.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/wasm/nxt_rt_wasmtime.c')
-rw-r--r--src/wasm/nxt_rt_wasmtime.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/src/wasm/nxt_rt_wasmtime.c b/src/wasm/nxt_rt_wasmtime.c
index 99786b89..7f05fae0 100644
--- a/src/wasm/nxt_rt_wasmtime.c
+++ b/src/wasm/nxt_rt_wasmtime.c
@@ -102,6 +102,19 @@ nxt_wasm_send_headers(void *env, wasmtime_caller_t *caller,
}
+static wasm_trap_t *
+nxt_wasm_set_resp_status(void *env, wasmtime_caller_t *caller,
+ const wasmtime_val_t *args, size_t nargs,
+ wasmtime_val_t *results, size_t nresults)
+{
+ nxt_wasm_ctx_t *ctx = env;
+
+ ctx->status = args[0].of.i32;
+
+ return NULL;
+}
+
+
static void
nxt_wasmtime_execute_hook(const nxt_wasm_ctx_t *ctx, nxt_wasm_fh_t hook)
{
@@ -123,8 +136,8 @@ nxt_wasmtime_execute_hook(const nxt_wasm_ctx_t *ctx, nxt_wasm_fh_t hook)
}
-static void
-nxt_wasmtime_execute_request(const nxt_wasm_ctx_t *ctx)
+static int
+nxt_wasmtime_execute_request(nxt_wasm_ctx_t *ctx)
{
int i = 0;
wasm_trap_t *trap = NULL;
@@ -142,7 +155,10 @@ nxt_wasmtime_execute_request(const nxt_wasm_ctx_t *ctx)
nxt_wasmtime_err_msg(error, trap,
"failed to call function [->wasm_request_handler]"
);
+ return -1;
}
+
+ return results[0].of.i32;
}
@@ -183,6 +199,11 @@ nxt_wasmtime_set_function_imports(nxt_wasm_ctx_t *ctx)
.func = nxt_wasm_send_headers,
.params = { WASM_I32 },
.ft = NXT_WASM_FT_1_0
+ }, {
+ .func_name = "nxt_wasm_set_resp_status",
+ .func = nxt_wasm_set_resp_status,
+ .params = { WASM_I32 },
+ .ft = NXT_WASM_FT_1_0
},
{ }