summaryrefslogtreecommitdiffhomepage
path: root/src/wasm/nxt_wasm.h
diff options
context:
space:
mode:
authorAndrew Clayton <a.clayton@nginx.com>2023-09-08 21:51:25 +0100
committerAndrew Clayton <a.clayton@nginx.com>2023-09-25 13:49:36 +0100
commit76086d6d7a027ddf42d86897200a53d724fb4bb7 (patch)
treeac1b5f1a4c64641d0510e9ab289ffd1a99b47beb /src/wasm/nxt_wasm.h
parentc9961610ed5651bda63191465e70e8227c3ef711 (diff)
downloadunit-76086d6d7a027ddf42d86897200a53d724fb4bb7.tar.gz
unit-76086d6d7a027ddf42d86897200a53d724fb4bb7.tar.bz2
Wasm: Allow to set the HTTP response status.
This commit enables WebAssembly modules to set the HTTP response status to something other than the previously hard coded '200 OK'. To do this they can make a call to nxt_wasm_set_resp_status() providing the required status code. If this function isn't called the status code defaults to '200 OK'. The WebAssembly module can also return -1 from the request_handler function as a short cut to signal a '500 Internal Server Error'. Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
Diffstat (limited to 'src/wasm/nxt_wasm.h')
-rw-r--r--src/wasm/nxt_wasm.h4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/wasm/nxt_wasm.h b/src/wasm/nxt_wasm.h
index cb9dbdfe..2748d764 100644
--- a/src/wasm/nxt_wasm.h
+++ b/src/wasm/nxt_wasm.h
@@ -118,12 +118,14 @@ struct nxt_wasm_ctx_s {
size_t baddr_off;
size_t response_off;
+
+ uint16_t status;
};
struct nxt_wasm_operations_s {
int (*init)(nxt_wasm_ctx_t *ctx);
void (*destroy)(const nxt_wasm_ctx_t *ctx);
- void (*exec_request)(const nxt_wasm_ctx_t *ctx);
+ int (*exec_request)(nxt_wasm_ctx_t *ctx);
void (*exec_hook)(const nxt_wasm_ctx_t *ctx, nxt_wasm_fh_t hook);
};