     send_response({:reply, type, nil, state}, socket_state, req)
   end
 
+  @doc """
+  Sets up a websocket proxy to a given `proxy`.
+
+  The `state` is modified to add in the new proxy, while `req` is returned untouched.
+  """
   @spec setup_proxy(proxy :: String.t, state :: map, req :: :cowboy_req.req) ::
     {:reply, {:text, String.t}, :cowboy_req.req, map}
     | {:ok, :cowboy_req.req, map}

      end

      ## Incoming from client / browser
      @spec websocket_handle(
        {:text, String.t},
        req :: :cowboy_req.req,

    end
  end

  @doc ~S"""
  Send a JSON encoded to the websocket client.

  The given `message` is JSON encoded (exception: `:noreply`).
  The `socket_state` is used updated to reflect changes made by the client.
  The cowboy `req` is returned untouched.
  """
  @spec send_response(
    message ::  {:noreply, any}
              | {:reply, atom | list(atom), any}
