-module(cowmachine_websocket_upgrade).

-export([
    upgrade/2
    ]).

%% @doc Upgrade the request to a websocket request
-spec upgrade(atom(), cowmachine_req:context()) -> {ok, cowboy_req:req(), cowboy_middleware:env()}.
upgrade(Handler, Context) ->
    Req = cowmachine_req:req(Context),
    Env = #{},
    cowboy_websocket:upgrade(Req, Env, Handler, Context, infinity, run).

-module(cowmachine_websocket_upgrade).

-export([
    upgrade/2
    ]).

%% @doc Upgrade the request to a websocket request
-spec upgrade(atom(), cowmachine_req:context()) -> {ok, cowboy_req:req(), cowboy_middleware:env()}.
upgrade(Handler, Context) ->
    Req = cowmachine_req:req(Context),
    Env = #{},
    Opts = #{
        idle_timeout => infinity
    },
    cowboy_websocket:upgrade(Req, Env, Handler, Context, Opts).

Fix websocket upgrade for cowboy 2.0.0-pre.10
Fix websocket upgrade for cowboy 2.0.0-pre.10
