From 165f36ec78029031b5084e574a6c7a507887250c Mon Sep 17 00:00:00 2001 From: Niclas Axelsson Date: Sun, 9 Aug 2026 14:36:18 +0200 Subject: [PATCH] Be able to return {status, ...}-tuple when upgrading websocket. Uses the registered handler and sets response accordingly. Relates to #394 --- src/nova_basic_handler.erl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/nova_basic_handler.erl b/src/nova_basic_handler.erl index 6fbb4e1..74c3175 100644 --- a/src/nova_basic_handler.erl +++ b/src/nova_basic_handler.erl @@ -254,6 +254,10 @@ handle_websocket({websocket, ControllerData}, Callback, Req) -> case Module:init(ControllerData) of {ok, NewControllerData} -> {cowboy_websocket, Req#{controller_data => NewControllerData}, #{}}; + %% We also support status tuples + StatusTuple when is_tuple(StatusTuple), element(1, StatusTuple) =:= status -> + {ok, HandlerMod} = nova_handlers:get_handler(status), + HandlerMod(StatusTuple, Callback, Req); Error -> ?LOG_ERROR(#{msg => <<"Handler returned unsupported result">>, handler => Module, return_obj => Error}), %% Render 500